-
Notifications
You must be signed in to change notification settings - Fork 2
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
Equivalent Rx example #4
Comments
Thanks for your question! We have something roughly equivalent in the web app counter example. The closest direct port would look like: const {start, flow, events, map, observe} = FairmontReactive;
var counter = { value: 0 };
start(flow([
events('click', incEl),
map(_ => counter.value++)
]));
start(flow([
events('click', decEl),
map(_ => counter.value--)
]));
start(flow([
events('change', observe(counter)),
map(::console.log)
])); There's no equivalent at present of const {start, flow, events, map, observe, merge, scan} = FairmontReactive;
var inc = flow([
events('click', incEl),
map(_ => 1)
]);
var dec = flow([
events('click', decEl),
map(_ => -1)
]);
start(flow([
merge(inc, dec),
scan((a, b) => a + b, 0),
map(::console.log)
])); |
We're also considering a function const {start, flow, events, map, observe, merge, scan} = FairmontReactive;
var inc = flow(events('click', incEl), map(_ => 1)));
var dec = flow(events('click', decEl), map(_ => -1)));
go(
merge(inc, dec),
scan((a, b) => a + b, 0),
map(::console.log)
); |
Made a bunch of minor corrections to the code above. |
|
Also coded up |
@dyoder What is |
@xgrommx This is implemented and available in Beta 29. There is a bug: see #8. So the equivalent of your original example is now: var inc = flow(events('click', incEl), map(_ => 1)));
var dec = flow(events('click', decEl), map(_ => -1)));
go(
combine(inc, dec),
accumulate((a, b) => a + b, 0),
map(::console.log)
); Thanks again for your question and for motivating these new additions. |
@dyoder Nice! Also your library was added to my book http://xgrommx.github.io/rx-book/content/similar_libraries/index.html =) |
@xgrommx that is amazing list. by far the most comprehensive i've seen. thank you! |
Hi @dyoder. How can I convert this example to your library?
The text was updated successfully, but these errors were encountered: