Closed Bloomca closed 1 month ago
Okay, so implementing is pretty simple, but thinking about it, maybe it is not necessary.
These two things are equivalent:
Using combine and select:
const nameState = createState("");
const lastNameState = createState("");
const fullNameState = select(
combine(nameState, lastNameState),
([firstName, lastName]) => `${firstName} ${lastName}`
);
And this is using reduce:
const nameState = createState("");
const lastNameState = createState("");
const fullNameState = reduce(
[nameState, lastNameState],
([firstName, lastName]) => `${firstName} ${lastName}`
);
Honestly, the advantage is very small, so I think I'll just close this issue. I think the state system needs a rework to allow at least Rxjs to be compatible (similar to how
Description
From my testing with lucy-state, I think
useReduce$
is probably the most useful helper, so I think we need to introduce it as well.It can be practically copied from https://github.com/Bloomca/react-lucy-state/blob/main/src/utils/reduce.ts, with small tests adjustment.