-
-
Notifications
You must be signed in to change notification settings - Fork 234
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
Deprecate derived units in target
#563
Comments
So we need to add such validations to:
Anything else? |
Maybe add validation on the kernel level? To add support for patronum |
This is added to the metadata of the graph node anyway, assume usage in that way: if (unit.graphite.meta.derived) throw Error('derived unit cannot be used as a target') Even more, this is already implemented like that |
target
target
I updated a REPL example a bit:
|
@AlexandrHoroshih thanks, I wrote more tests based on your findings |
tests with direct calls of derived units returned by methods: - merge - split - sample - guard tests with derived units in targets of methods: - split - sample - guard - forward each `undefined` snapshot is a place where should be a warning related issue #563
affected methods: - merge - split - sample - guard related issue #563
affected methods: - sample target - guard target - split cases - forward to related issue #563
I cannot agree. const nameChanged = createEvent<string>();
const $name = restore(nameChanged, ''); But in real life you want to reset form and load data to form fields: $name.reset(formCleanup);
spread({
source: formLoadFx.doneData,
targets: {
name: $name,
},
}) As we see it is a common store, not derived. |
It is how it works know, yes, but same works for mapped stores now and this behavoir is still deprecated for a reason But yeah, restored event is probably not a derived store, because its state definitely should be transferred over the network during SSR - otherwise app rendered on the client will be different from the render at server |
Not the same semantics. Mapped store it the explicit contract with the single source of truth (single source of updates). Here we proof store has no updates source except $b = $a.map(fn) Here the same, but source of updates is $e = combine($c, $d, (c, d) => c + d) |
Deprecation warning will be published in the next minor release |
What is the current behavior:
Usage of
.on
method is deprecated on derived stores and to be removed in the next release - this is very good news and, i think, makes everything a lot more consistent and predictable 👍But now usage of derived stores as a
target
in operators is not warned or error by effector, so the problem of unexpected changes to derived stores still persists 😢Also i think that stores created by restore from an event or effect should be considered as derived too, since they also have explicit dependency at the moment of creation: restore(changed, null) 🤔
UPD: Since restored event state still can be used by app and can't be derived from, for e.g., state in serialized scope during SSR, it is definetly not derived (at least, in a sense similiar to mapped stores)
Please provide the steps to reproduce and if possible a minimal demo of the problem via https://share.effector.dev, https://codesandbox.io or similar
https://share.effector.dev/yqvd359F
What is the expected behavior:
Any attempt of adding a new source of updates to dervied store is forbidden and warning/error is shown.
If such behaviour is needed - it is better to create classic (not derived) store and subscribe it to changes of original derived store.
Which versions of effector packages, and which browser and OS are affected by this issue? Did this work in previous versions of effector?:
effector@22.0.0^
The text was updated successfully, but these errors were encountered: