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

Is it ok that prev and state in onStateChange handler return same values? #77

Open
voronianski opened this issue Dec 5, 2016 · 4 comments

Comments

@voronianski
Copy link

voronianski commented Dec 5, 2016

Please take a look at my example (pls open console to see logs).

On every 'counter:increment' action onStateChange handler logs the same values for state.counter.count in state and prev objects:

image

Is it intended?

@voronianski
Copy link
Author

voronianski commented Dec 6, 2016

Also I'm a bit confused that inside choo.js onStateChange function has different signature - https://github.com/yoshuawuyts/choo/blob/master/index.js#L89

@voronianski
Copy link
Author

@yoshuawuyts I really like the concepts and minimal API of the library and would like to use it inside of my project but this issue stops me for now.

@yoshuawuyts
Copy link
Owner

currently thinking of actually ditching the prev argument because it causes a fair amount of complexity in the API - wouldn't rely on it tbh

@yoshuawuyts
Copy link
Owner

Instead you can hold your own reference to the prev instance of state, for example inside a closure (:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants