Open mAAdhaTTah opened 4 years ago
useEddyReducer
would be similar to useReducer
except it would:
loop
s & dispatching back into itself.It would be nice to be able to compose this with useDeltaReducer
under the hood.
useState$
, which is like useReducer
but returns an Observable of state
instead.
const [state$, dispatch] = useState$(reducer, initialState, init);
You could then use useMutableSource
to unwrap the value for rendering. This might be usable under the hood, maybe with useEddyReducer
, to compose up into useDeltaReducer
. Would be nice if overall you could mix and match to build your preferred API.
I'm not sure how ergonomic passing Observables around will be (especially in TypeScript), but this is just an idea.
I think there's a lot of improvement that could be made to the hooks that could eventually move us away from Redux completely, but I'm not in love with all of the APIs yet. There's also an incoming hook called
useMutableSource
that we could take advantage of, either inbrookjs
directly or in thekefir
org. This might suggest different APIs inbrookjs
.Also, taking a note from
useSagaReducer
, we might want to moveuseDelta
touseDeltaReducer
and change the API to look like this:This makes it looks more like
useReducer
and theinitialState
&init
APIs are much better for bootstrapping the reducer than what we have. We could then createroot$
with auseRootDispatch
:We could consider changing the name of this prop as well, and this could be used to plug the
RootJunction
into the standarduseReducer
.Lastly, instead of
toJunction
, we could enable it's functionality withuseJunction
:to enable callbacks to plug into the
CentralObservable
. We'd still need a replace for thecombiner
part of the API though, which might require another HOC-style API.These are just some ideas. Opening this to track & discuss other ideas.