-
Notifications
You must be signed in to change notification settings - Fork 46
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
docs: add introduction.md #354
Merged
Merged
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
37e53d4
docs: add introduction.md
DammneD 2d1b2a9
docs: fix path to asset
DammneD 127d14d
docs: change description
DammneD 7f4562e
docs: change some description
DammneD bbb009b
docs: change some description
DammneD 33ddc9d
docs: global change introduction.md
DammneD 7271fd1
docs: add some assets
DammneD 9ea44fc
docs: add recap
DammneD a147916
docs: some description changes
DammneD 63bf802
docs: change description
DammneD 3e7501e
docs: minor changes
DammneD 0e25598
docs: minor changes
DammneD d5bb06f
docs: fix description
DammneD fc97bde
docs: fix description
DammneD 1735b21
docs: visual fix
DammneD File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,52 @@ | ||||||||||
# Introduction | ||||||||||
|
||||||||||
Most JavaScript frameworks come with a dedicated routing solution like `angular/router` or `vue-router`. | ||||||||||
They allow you to navigate through pages of an application without a full page refresh on every click. | ||||||||||
|
||||||||||
## Problem statement | ||||||||||
|
||||||||||
When you have a monolithic application, it handles all the routes on its own. When there are two or more applications, they also handle all their routes independently. Since, by default, one independent application know nothing about routes and pages of other independent application. This gives you a problem to solve - a routing issue. | ||||||||||
|
||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
## Routing basics | ||||||||||
|
||||||||||
Before proceeding with details on how the issue is handled by ILC, get familiar with the basics of routing in the micro-frontends and terminology: | ||||||||||
|
||||||||||
- **Hard navigation** describes a page transition where the browser | ||||||||||
loads the complete HTML for the next page from the server. | ||||||||||
- **Soft navigation** describes a page transition that is rendered entirely on the client-side, typically by using a client-side router. In this scenario, the client fetches data from the server via API. | ||||||||||
|
||||||||||
## Solution | ||||||||||
|
||||||||||
There are several approaches to implement navigation. The common ones are described below: | ||||||||||
|
||||||||||
1. Page transitions happen via plain links, which results in a full page refresh. To proceed with this approach, Team A must know how to link to the pages of Team B and vice versa. No special tooling is required. | ||||||||||
1. All transitions inside team boundaries are soft. Hard navigation happens when the user crosses team boundaries. From an architectural perspective, this approach is the same as the first one because Team A still has to know how to link to the pages of Team B (and vice versa) regardless of the details of the internal implementation. | ||||||||||
|
||||||||||
![Introduction demo](../assets/routes/introduction-demo.png) | ||||||||||
|
||||||||||
ILC uses a third approach called **Unified SPA** (Unified Single-page application). It introduces a central application container (that is, ILC) that handles page transitions between the teams. In this approach, all the transitions are soft. | ||||||||||
|
||||||||||
![Introduction demo](../assets/routes/introduction-demo2.png) | ||||||||||
|
||||||||||
Implementation of routing in ILC: | ||||||||||
|
||||||||||
In ILC, you can use one HTML template for all of your applications. With this approach, page load occurs only once (during the first time load), after that all navigation occurs via CSR (client-side rendering). In addition to the fact that all navigation inside the ILC is soft, it also uses **two-tiered routing** which, unlike the **flat routing** approach - where, in ILC, you need to specify a full URL of each page of all your applications, allows we to specify only a base URL of the application in the ILC and that's it, we don't need to know the full route to each page of the application. All navigation within the application can be implemented by each development team using their application's own tools (for example, react-router, or vue-router). | ||||||||||
|
||||||||||
!["2-tiered routing" approach](../assets/2_tiered_routing.png) | ||||||||||
|
||||||||||
In the example above, the user opened the `/news/latest` page URL. ILC checks the first part of the URL (`/news/`) to determine the assosiated application. It correlates to the `/news/*` route configured in ILC. This route contains information about applications that should be loaded on the page and props these applications need to receive. When the application is loaded and mounted to its container DOM node, it also receives `basePath` property that should be used by application's router. The application's router processes the complete URL to find the correct page inside its SPA. | ||||||||||
|
||||||||||
You can use native tools (for example `<Link>` in `React router`) to navigate between pages within the application, and `global link` - a link (`<a>` tag) to navigate between applications. | ||||||||||
|
||||||||||
In ILC, as mentioned before, the transition between applications occurs via the `<a>` tags. To do this, ILC keeps track of all `<a>` tags on the page and handles clicks on them, provided that: | ||||||||||
|
||||||||||
1. Tag contains a non-empty `href`. | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Indent a list with a blank line |
||||||||||
1. `event.PreventDefault` does not equal `false`. | ||||||||||
1. `target`does not equal `_self`. | ||||||||||
1. This is not a special url (`mailto`, `tel`, etc). | ||||||||||
|
||||||||||
If one of the above points is not met, ILC ignores the processing of the clicks on the link. | ||||||||||
|
||||||||||
### Conclusion | ||||||||||
|
||||||||||
ILC acts as a wrapper for other applications making all the transitions soft. Furthermore, it uses two-level routing so that teams can configure routing inside their application as they need to, whereas, in ILC, you only need to specify the path to the application. | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Indent a heading with a blank line |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move this under the introduction