Type alias Editor<T>

Editor<T>: ((draft) => void)

Type Parameters

  • T

Type declaration

    • (draft): void
    • A function passed to edit. The editor is called back with a draft - a mutable proxy of the Store's current Immutable RootState.

      You can make changes to the mutable draft proxy within your editor callback using any javascript syntax. When it returns, Immer efficiently composes a new @lauf/store.Immutable state to reflect your drafted changes, leaving the old state intact. The new state is passed to @lauf/store.Store#write.

      The editor is equivalent to Immer's producer except returning a value doesn't replace the @lauf/store.RootState. To replace the state call @lauf/store.Store#write instead of using an editor. This eliminates Immer's runtime errors when you draft changes as well as returning a value, (easily done by accident in simple arrow functions).

      See Immer docs for more detail on the conventions for Immer producers.

      Parameters

      • draft: Draft<T>

        A mutable proxy of a @lauf/store.Store's existing Immutable state. Manipulate this object to compose the next state.

      Returns void

Generated using TypeDoc