Skip to content
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

TypeError: eff.cancel is not a function (when assigning function effect twice) #3

Closed
hex13 opened this issue Aug 22, 2018 · 1 comment
Labels
bug Something isn't working

Comments

@hex13
Copy link
Owner

hex13 commented Aug 22, 2018

steps to reproduce:

        const store = createStore({
            a: init(0).on('foo', () => () => 1)
        }, createFeedbacks());
        store.dispatch({type: 'foo'});
        store.dispatch({type: 'foo'});
 TypeError: eff.cancel is not a function
  at visitNode (src/resmix.js:350:37)
  at visitNode (src/resmix.js:367:29)
  at Object.action [as dispatch] (src/resmix.js:371:17)

How it should work and why this bug occurs:

Feedbacks is designed to auto-cancel previous effect on same property.
e.g. () => new Observable(...) cancel previous observable bound to property.

But effects can be various things (including functions) and when a function is returned, Feedbacks somewhat wants to cancel previous function by calling result.cancel() when result is a result of running effect in EffectRunner. But EffectRunner doesn't always return cancellable result.

So either it should cancel previous function or just checking if eff.cancel exists in result.

@hex13 hex13 added the bug Something isn't working label Aug 22, 2018
@hex13 hex13 mentioned this issue Aug 22, 2018
25 tasks
@hex13 hex13 closed this as completed in b9e4f4a Aug 22, 2018
@hex13
Copy link
Owner Author

hex13 commented Aug 22, 2018

I added checking if eff.cancel exists for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant