-
Notifications
You must be signed in to change notification settings - Fork 9
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
deriving fsm #8
Comments
You're not wrong. I've just today encountered this, too, and for me, it's a showstopper. The good news is that I've dug in and I believe I may have found the issue. I still don't know what to do about it, but I know where it is. The problem is that Svelte stores are no longer quite so simple as to work with a single callback argument, so the derived store is misinterpreted as requesting an action rather than a subscribe, therefore, no derived store can correctly subscribe. I'm surprised this even works on the rest of Svelte, to be honest. I am not a huge fan of proxying anyway -- I'd probably rather have an explicit action invocation method (say, an It's even mentioned in the code: https://github.com/kenkunz/svelte-fsm/blob/96631f9da3ae510ab75341776305fee619fcdfa2/index.js, lines 59 to 73 "subscribe also behaves as an event invoker when called with any args other than a single callback" -- the problem is that Svelte itself will generate subscribes like this, even if you don't. In fact, there's sometimes a second invalidator argument to
One solution would be to stop using number of arguments to detect a "real" subscribe, which would mean that "subscribe" becomes more or less a reserved action as it couldn't be invoked the same way. Although personally I don't think this overloaded subscribe trick is worth allowing anyway. Which is a roundabout way of saying that for this module, |
@morungos Thank you for your detailed research and great insights. I could not have understood it in that depth. I am glad that I was not wrong, but rather that I was able to clarify this issue. I don't have the ability to provide a fix, but I hope this module will be even better and further accelerate development at Svelte. |
@kenkunz I have no idea why the second commit is it into the PR. I need it for my app and pushed it, but it's completely unrelated to this issue. I'll switch that to a branch for my private usage and remove from this PR. But it may take me a few hours to get to that as I'm away from dev tools right now. The only commit to look at should be: 881e9ec That second commit might be of interest, but it relates to automatic event less transitions, which is a much bigger issue. |
Thanks for clarifying, @morungos. |
OK, updated the PR now. Should be easier to review. Sorry it took so long to get to this. |
I'm just following up on my to-do list. Turns out, that second commit I removed earlier, which was about adding eventless transitions, has been incredibly useful (aka, more or less essential) to our project, and they weren't hard to add in. If you're interested, check out: morungos@0955042 I'd be more than happy to make that a pull request too (we don't really want to maintain a fork), but if not, it can stay independently where it is. |
Thanks for publishing this great module.
I want to make a derived store from fsm.
Please take a look the following repl.
https://svelte.dev/repl/5448ab6468704700ae1c2db736a0ac44?version=3.48.0
Accessing derived store from fsm with $ causes this error.
Cannot read properties of undefined (reading 'unsubscribe')
Please let me know if I am wrong in any way.
Thanks.
The text was updated successfully, but these errors were encountered: