aurelia / documentation

The documentation for Aurelia.
MIT License
105 stars 111 forks source link

docs(dispatch): piped dispatch explanation #416

Closed zewa666 closed 5 years ago

zewa666 commented 5 years ago

Explanation and sample for the piped dispatch feature

zewa666 commented 5 years ago

@gins3000, you might want to give this one a look as well as a simple intro to your previously added feature.

zewa666 commented 5 years ago

@EisenbergEffect, should be timed together with the next minor release of the Store plugin

gins3000 commented 5 years ago

@gins3000, you might want to give this one a look as well as a simple intro to your previously added feature.

@zewa666, this is already looking good, I have a few suggestions:

  1. In the first paragraph you say 'call dispatch multiple times [...] would [...] distort your history'. Assuming you mean StateHistory, this doesn't actually get 'fixed' with piped dispatch, as it just executes all piped actions one after another, and, as the actions themselves are responsible for modifying the history state, they will all still do so even when executed as part of a pipeline.

    Instead, I would recommend to add a notice about this behavior specifically, along the lines of:

    When using StateHistory, the history state is still updated for each individual action as if they were called separately. This leaves you fully in control of your state history. For example if you would like to merge the history transitions of piped actions into a single history transition, you could write an action that does this and append it to your pipe.

    I could provide a code snippet for this, if wanted.

  2. It could be useful to mention

    • that piped actions show up in the format action1->action2 in the Redux DevTools as well as in middleware's action.name
    • that a middleware's action.params contains all the parameters of the piped actions in a single array
    • and that the details of the individual pipeline actions can be accessed in middlewares via the action.pipedActions array, if needed.

Looking forward to the release of this feature :)

zewa666 commented 5 years ago

Yep, a sample of what you're thinking of would be definitely helpful. Part two has been addressed with the latest commit