Add sync dispatch option to FleurContext
petamoriken opened this issue · 2 comments
When used requestAnimationFrame
in the View, e.g. game development with react-pixi, state of the Store changes with delay of a frame. Add to an option to change the status to Operation#dispatch
immediately.
context.dispatch(identifier, payload, { asap: true });
This option should be ignored in SSR.
Alternative:
interface DispatchOptions {
/** default: "animationFrame" */
clientSideQueue: null | "microTask" | "task" | "animationFrame";
}
FYI: RxJS Scheduler types
Thanks for open issue!
I understand the need for a synchronous dispatch
.
However, I don't think it's wise to add a synchronization option for dispatch
. This is because it exposes the Operation layer to how the Action is processed by the View and gives room for timing-dependent complexity.
A better idea for using Fleur for react-pixi-fiber, in my opinion, is to specify how dispatch is handled in FleurContext. This is because it allows for consistent processing of Actions within the application.
Ex.
<FleurContext value={context} options={{
batchedUpdate: (cb) => cb,
synchronousDispatch: true,
}} />
If you need a synchronization option on a per-dispatch basis, I'd like to hear why.
@hanakla Nice idea! It will solve my problem.