- Inside
src/lib.ts
lies the library code. - Inside
src/app.ts
lies an example application.
- Use React in your application (you can use the vanilla Store class if you don't use React, but there's way better stuff out there)
- Create a type definition for your state and actions (see example in
src/app.ts
) - Create an anonymous class, extending from
ComponentStoreHelper
. Pass the state/action types to the generic slots. - Use your editor's "quick fix" code completion to auto-fill necessary overrides
- Return default state from
provideDefaultState
, setup reducer method (produceNextState) to transition between states given actions - Wrap your React components with the
<Provider />
function component inside the object you've just made. - Use
useSelector
anduseDispatch
within children of the wrapper to subscribe to state changes in the store - Now, you're free to hoist state and only re-render exactly what you need. Just keep state as close to where you need it as possible, writing UI in a straightforward way with minimal/no prop-drilling required.