You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The rationale is to keep multiple (huge) collections consistent / in sync, without the need to recalculate the derived from scratch.
Eg. if I set an ObjectMap's key to 10, I'd like to subscribe to this setmodelAction via onActionMiddleware and automatically set (with fast mutation, instead mobx-ish "pure recalculation") another ObjectMap's same key based on a mapper function (x=>2*x) to 20. I want them to happen in same transaction.
I assume it is not a good idea to inject such "business logic"(?) in the middleware layer, but I can not think of any other way to do it in a reactive (and not passive) way in keystone. (Mobx has observe, but it does not respect transactions and keystone onPatches only run at the end of the transactions if I am right, which is "too late" to keep data consistent that way.)
The text was updated successfully, but these errors were encountered:
My point is about having the freedom to eliminate "recalculation" (from scratch). I am totally fine if 95% of my app works with recalculation (it's easier to reason about + simpler code), but that 5% must rely on deep observation and listening to deep changes and propagating these deep changes solely. Also, this part must be reactive and can not be passive. (Explicit mutation of mapped is not good enough, does not scale regarding DX.)
As onPatches does not help inside of a transaction, my attempts was to treat actions like these changes events which "needs to be propagated". For that, I'd need the freedom to nest "onAction"s and as part of that, to emit new actions.
Just and idea: it would be nice if we could insert a callback (eg used with standaloneAction) before and especially after an action. So, beyond onStart and onFinish there could be a beforeStartStandaloneAction and afterFinishStandaloneAction - as sibling actions, respecting the boundaries.
However it would be also interesting something like afterStartStandaloneAction and beforeFinishStandaloneAction which could be ("pseudo")children actions of the target action, called before/after anything else in the action.
Is my assumption good, that currently it is not valid to start actions in onActionMiddleware hooks?
The rationale is to keep multiple (huge) collections consistent / in sync, without the need to recalculate the derived from scratch.
Eg. if I
set
an ObjectMap's key to 10, I'd like to subscribe to thisset
modelAction
viaonActionMiddleware
and automaticallyset
(with fast mutation, instead mobx-ish "pure recalculation") another ObjectMap's same key based on a mapper function (x=>2*x) to 20. I want them to happen in same transaction.I assume it is not a good idea to inject such "business logic"(?) in the middleware layer, but I can not think of any other way to do it in a reactive (and not passive) way in keystone. (Mobx has observe, but it does not respect transactions and keystone onPatches only run at the end of the transactions if I am right, which is "too late" to keep data consistent that way.)
The text was updated successfully, but these errors were encountered: