Interface Reshaper<T>

A Reshaper is the primary object of reshape-state and is responsible for managing updates to a state object.

interface Reshaper<T> {
    addHandlers: ((handlers) => Reshaper<T>);
    addOnChange: ((onChange) => Reshaper<T>);
    dispatch: Dispatcher<T, unknown>;
    removeHandlers: ((handlers) => Reshaper<T>);
    removeOnChange: ((onChange) => Reshaper<T>);
    setGetState: ((getter) => Reshaper<T>);
}

Type Parameters

  • T

    The type of the state object.

Properties

addHandlers: ((handlers) => Reshaper<T>)

Add handlers that will be invoked to process a dispatched Action.

Type declaration

Returns

The Reshaper.

addOnChange: ((onChange) => Reshaper<T>)

Add an onChange callback. Only a single callback can be passed to this function but the function can be invoked multiple times to add multiple callbacks.

Type declaration

Returns

The Reshaper.

dispatch: Dispatcher<T, unknown>

Dispatch one or more Actions or InlineHandlers to update state.

Template: T

The type of the state object.

removeHandlers: ((handlers) => Reshaper<T>)

Remove an array of handlers.

Type declaration

Returns

The Reshaper.

removeOnChange: ((onChange) => Reshaper<T>)

Remove an onChange callback.

Type declaration

Returns

The Reshaper.

setGetState: ((getter) => Reshaper<T>)

Provide a function that returns the current state when invoked. The return value of getter will be passed to the handlers.

Type declaration

Returns

The Reshaper.