low: add signal combine
betula opened this issue · comments
const a = value(0);
const s = signal.combine(a, () => a.val + 1); // readonly
s.watch(
([a, a_plus_one]) => console.log(a, a_plus_one)
);
// And I think it's possible to make `value.combine`
// Should be detected changes in each value and if some of them changed, fire changes outside
const v = value.combine(a, () => a.val + 1); // readonly
const value_combine = (...args) => {
const sels = args.map((fn) => sel(fn)[0]);
return selector(() => sels.map(s => s()));
}
Will be perfect. I should check new typescript tuples, and update typescript for vscode.
value.combine(a, b, (a, b) => ({ a, b}));
or make value.combine.view
value.combine.view([a, b], (a,b) => ({ a, b })) // Perfect!
One more example
export const allReady = ready.from(
signal.combine(backReady, frontReady).flow.filter(([back, front]) => (
back && front
))
);
Simple combine added 4f007ce#diff-a2a171449d862fe29692ce031981047d7ab755ae7f84c707aef80701b3ea0c80R332
"value.combine" added in 0.6.0
"signal.combine" declined