nx-js / framework

A modular front-end framework - inspired by the server-side and Web Components.
https://nx-framework.com
MIT License
468 stars 30 forks source link

Why doesn't `exec` return values? #17

Closed fiatjaf closed 7 years ago

solkimicreb commented 7 years ago

exec executes an observer function. returning values from an observer function is not encouraged, as they can be triggered internally by observable mutations - not only by the user. they do stuff with side effects instead of return values (not only in nx-js, but generally in transparent reactive programming). allowing exec to return the value would make things inconsistent as it would encourage you to add a return value to your observers, which would never be used on internal triggers.

i hope this make sense. what is your use case?

fiatjaf commented 7 years ago

That's perfectly clear. My use-case was React rerendering, but I was doing it all wrong.

I found code from react-easy-state and almost solved my problems using it.

solkimicreb commented 7 years ago

Actually using exec on direct (React triggered) renders would be nicer there. I plan to refactor it in the future, as it relies on undocumented observe behavior.

fiatjaf commented 7 years ago

I just realize I'm posting on nx-js/framework instead of nx-js/observer-util. Sorry, I really thought I was on the other repo.

solkimicreb commented 7 years ago

Can I close this?