Executes a local handler function and manages the state of the data.

  • Type Parameters

    • Data extends unknown = any

      The type of the data that will be stored in the state.

    • Payload extends unknown = any

      The type of the payload that will be passed to the handler function.

    Parameters

    • handler: OneHandler<Data, Payload>

      The handler function to be executed.

    • Optionaloptions: ILocalHandlerParams<Data, any>

      Additional options for the local handler.

      Represents the parameters for a local handler

      • Optionalfallback?: (e: Error) => void
      • OptionalonLoadBegin?: () => void
      • OptionalonLoadEnd?: (isOk: boolean) => void
      • Optionalpayload?: Payload
      • OptionalresultMap?: (json: null | Record<string, any>) => null | Data

    Returns ILocalHandlerResult<Data>

    • An object containing the data and a function to change the data.