resetSubstore
Manages the full store reset lifecycle. A reset runs all registered callbacks in sequence, then executes a final afterReset callback (default: reload the page). Substores register their own reset logic via addResetCallback.
Table of contents
Properties
Methods
Properties
isResetting
isResetting: booleanWhether a reset operation is currently running.
Set to true when reset is called and back to false once all callbacks complete (or fail). Use this to show a loading indicator or disable the reset button during the operation.
Related
reset— the operation that sets this flag
afterReset
afterReset: ( set: ImmerSet<GlobalStore>, get: () => GlobalStore,) => void | Promise<void>Callback executed after all reset callbacks complete. Defaults to reloading the page.
Replace this with setAfterReset if you need custom post-reset behaviour (e.g., navigating to a different route instead of reloading).
Related
setAfterReset— setterreset— calls this after all registered callbacks run
Methods
reset
reset: () => voidTriggers a full store reset by running all registered callbacks in sequence.
- Sets
isResettingtotrue - Runs each callback registered via
addResetCallbackin order (awaiting async callbacks) - Runs
afterReset - Sets
isResettingback tofalse
All SDK substores automatically register their own reset callbacks, so calling reset() clears the entire store state.
Related
isResetting— flag managed during this calladdResetCallback— source of the callback listafterReset— final step executed after all callbacks
addResetCallback
addResetCallback: ( callback: ( set: ImmerSet<GlobalStore>, get: () => GlobalStore, ) => void | Promise<void>,) => voidRegisters a callback to be called during a reset operation.
Use this to hook into the reset lifecycle — for example, to clear your own application state alongside the SDK state. Callbacks are called in registration order. Async callbacks are awaited.
Parameters
| Name | Type | Description |
|---|---|---|
callback | ResetCallback | Function to run during reset. Receives Immer set and get for direct store mutation. |
Related
reset— executes all registered callbacks
setAfterReset
setAfterReset: ( callback: ( set: ImmerSet<GlobalStore>, get: () => GlobalStore, ) => void | Promise<void>,) => voidReplaces the post-reset callback with a custom implementation.
Use this when you want to navigate to a specific route or perform an async operation after the reset instead of reloading the page.
Parameters
| Name | Type | Description |
|---|---|---|
callback | ResetCallback | Replacement for the default page-reload callback |
Related
afterReset— the property this method writes