Skip to content

Commit a85725c

Browse files
authored
Fix plugin docs on order of middleware (#183)
* Fix incorrect statement that the order of plugins is arbitrary. I was wrong, it's the order they are registered. * Further fix
1 parent da2fdc5 commit a85725c

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

documentation/docs/core-concepts/anatomy-of-a-request.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@ We'll be using the following example for this discussion.
1111

1212
```js
1313
const app = new App();
14-
app.register(FirstPlugin);
1514
app.register(SecondPlugin);
1615
app.register(StandalonePlugin);
16+
app.register(FirstPlugin);
1717
```
1818

19-
> **NOTE**: The actual ordering of registration here does not matter since Fusion.js will resolve all plugin dependencies when your app loads. This greatly simplifies configuration of your app since you don't need to manually re-order things around!
19+
> **NOTE**: You do not need to manage the ordering of registrations here if any of the plugins have dependencies on each other. Under the hood, Fusion.js will sort out the dependency graph for you.
2020
2121
Let's also assume that `SecondPlugin` depends on `FirstPlugin` but `StandalonePlugin` is stand-alone with no dependencies.
2222

@@ -54,14 +54,14 @@ When Fusion.js initializes, it builds a dependency graph of all registered plugi
5454
In the above example, because `SecondPlugin` depends on `FirstPlugin`, the `console.log` order that the middleware will be accessed is:
5555

5656
1. `FirstPlugin`
57-
2. `StandalonePlugin`
58-
3. `SecondPlugin`
57+
2. `SecondPlugin`
58+
3. `StandalonePlugin`
5959

60-
> **Note**: The order of `FirstPlugin` and `StandalonePlugin` is not deterministic since both are not dependent on anything else. This is ok in our case though since we have no preference.
60+
This ordering occurs even though `SecondPlugin` was registered earlier than `FirstPlugin` and `FirstPlugin` was registered last, after `StandalonePlugin`. Under the hood, Fusion.js will process plugins in the order that they are registered unless they have a dependency on another plugin, in which case that plugin is processed ahead of it. This causes `FirstPlugin` to be processed first by proxy of `SecondPlugin` and thus ahead of `StandalonePlugin`.
6161

6262
### Server rendering
6363

64-
After all plugins have run, the last task is to render out the current page on the server. This is **always** the last action that the server takes. This presents an opportunity for registered plugins to modify the HTML template if necessary to add/remove HTML elements while the request chain is processing.
64+
After all plugins have run, the last task is to render out the current page on the server. This is **always** the last action that the server takes. This presents an opportunity for registered plugins to modify the HTML template if necessary to add/remove HTML elements in any middleware.
6565

6666
Finally, the server render will flush the page HTML onto the client.
6767

0 commit comments

Comments
 (0)