We just open-sourced the state management library we built for Frontman (https://frontman.sh). It’s a small ReScript-native library that gives you two things:
- StateReducer — local component state, like useReducer but with managed side effects
- StateStore — global store with concurrent-safe selectors via useSyncExternalStoreWithSelector
The core idea is Elm-style: your next function is pure and returns (state, array). Effects are values, not callbacks — they run after the state update, so your reducers are trivially testable.
let next = (state, action) => {
switch action {
| Increment =>
StateReducer.update(
{count: state.count + 1},
~sideEffect=LogCount(state.count + 1),
)
| Decrement => StateReducer.update({count: state.count - 1})
}
}