re-state
API Reference

resetReState

resetReState restores every registered key at once. It is useful for logout, test cleanup, or another application-wide reset.

import { resetReState } from '@raulpesilva/re-state';

export function logout(): void {
  localStorage.removeItem('token');
  resetReState();
}

What reset does

  • Restores each key to its stored initial or custom reset value.
  • Notifies key subscribers and matching onReStateChange listeners.
  • Keeps the registered keys and subscriptions in place.
  • Does not run initializer functions again or clear browser storage.

An initial value is stored when a key is first initialized or written. setReStateInitialValue can replace that baseline.

To reset only one key, use the generated reset<Name> method from createReStateMethods.

API

function resetReState(): void;

On this page