-
Notifications
You must be signed in to change notification settings - Fork 0
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
The flow implementation #9
Comments
Proposal for add prev value to selector and flow sel((prev_value?) => {});
flow(init_, (stop?, prev_value?) => {}); And maybe remove flow(() => {
return get_a() + get_b();
}); I think: flow(init, (stop, prev_value?) => {});
flow((stop, prev_value?) => {});
flow(() => {}); Look likes perfect! |
Better syntax I think: flow(() => init, (stop, prev_value?) => {}, compare_fn?);
flow((stop, prev_value?) => {});
flow(() => {}); |
The final proposal of syntax: flow((stop?, prev_value?) => {}, empty_value?, compare_fn?); |
Proposal for breaked flow: flow((stop?, resolve?) => {}, empty_value?, compare_fn?); Example of using: // Awaiting flow
const b = box(0);
const f = flow((stop, resolve) => {
const v = b[0]();
setTimeout(() => resolve(v));
return stop;
});
expr(() => {
console.log(b[0](), f[0]());
})[0]();
b[1](1);
// 0, undefined
// 1, undefined
// 1, 0
// 1, 1 Or multiple resolves in one time const b = box(0);
const f = flow((stop, resolve) => {
const v = b[0]();
for (let i = 0; i < v; i++) resolve(i);
return 0;
});
expr(() => {
console.log(b[0](), f[0]());
})[0]();
b[1](3);
// 0, 0
// 3, 1
// 3, 2
// 3, 0 |
New issue created #10 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The text was updated successfully, but these errors were encountered: