Options
All
  • Public
  • Public/Protected
  • All
Menu

Module "effect-manager"

Index

Effect Manager

Effect Manager

EffectManager

EffectManager<Home, ProgramAction, SelfAction, SelfState, MyCmd, MySub>: { home: Home; mapCmd: <A1, A2>(actionMapper: (a1: A1) => A2, cmd: Cmd<A1>) => Cmd<A2>; mapSub: <A1, A2>(actionMapper: (a1: A1) => A2, sub: Sub<A1>) => Sub<A2>; onEffects: (dispatchProgram: Dispatch<ProgramAction>, dispatchSelf: Dispatch<SelfAction>, cmds: ReadonlyArray<MyCmd>, subs: ReadonlyArray<MySub>, state: SelfState) => SelfState; onSelfAction: (dispatchProgram: Dispatch<ProgramAction>, dispatchSelf: Dispatch<SelfAction>, action: SelfAction, state: SelfState) => SelfState; setup: (dispatchProgram: Dispatch<ProgramAction>, dispatchSelf: Dispatch<SelfAction>) => () => void }

A type that describes an effect manager that can be used by the "program".run function.

Type parameters

  • Home = string

  • ProgramAction = unknown

  • SelfAction = unknown

  • SelfState = unknown

  • MyCmd: Cmd<ProgramAction, Home> = Cmd<ProgramAction, Home>

  • MySub: Sub<ProgramAction, Home> = Sub<ProgramAction, Home>

Type declaration

  • Readonly home: Home

    All effect managers must have a unique Home string that is used to identify effects that should be routed to each effect manager. This is simply a string with the only constraint that is must be unique among all other effect managers that are used.

  • Readonly mapCmd: <A1, A2>(actionMapper: (a1: A1) => A2, cmd: Cmd<A1>) => Cmd<A2>

    This function is used when calling "cmd".map.

      • <A1, A2>(actionMapper: (a1: A1) => A2, cmd: Cmd<A1>): Cmd<A2>
      • Type parameters

        • A1

        • A2

        Parameters

        • actionMapper: (a1: A1) => A2
            • (a1: A1): A2
            • Parameters

              • a1: A1

              Returns A2

        • cmd: Cmd<A1>

        Returns Cmd<A2>

  • Readonly mapSub: <A1, A2>(actionMapper: (a1: A1) => A2, sub: Sub<A1>) => Sub<A2>

    This function is used when calling "sub".map.

      • <A1, A2>(actionMapper: (a1: A1) => A2, sub: Sub<A1>): Sub<A2>
      • Type parameters

        • A1

        • A2

        Parameters

        • actionMapper: (a1: A1) => A2
            • (a1: A1): A2
            • Parameters

              • a1: A1

              Returns A2

        • sub: Sub<A1>

        Returns Sub<A2>

  • Readonly onEffects: (dispatchProgram: Dispatch<ProgramAction>, dispatchSelf: Dispatch<SelfAction>, cmds: ReadonlyArray<MyCmd>, subs: ReadonlyArray<MySub>, state: SelfState) => SelfState

    This function will be called with effects emitted from the Program matching this manager's home.

      • (dispatchProgram: Dispatch<ProgramAction>, dispatchSelf: Dispatch<SelfAction>, cmds: ReadonlyArray<MyCmd>, subs: ReadonlyArray<MySub>, state: SelfState): SelfState
      • Parameters

        • dispatchProgram: Dispatch<ProgramAction>
        • dispatchSelf: Dispatch<SelfAction>
        • cmds: ReadonlyArray<MyCmd>
        • subs: ReadonlyArray<MySub>
        • state: SelfState

        Returns SelfState

  • Readonly onSelfAction: (dispatchProgram: Dispatch<ProgramAction>, dispatchSelf: Dispatch<SelfAction>, action: SelfAction, state: SelfState) => SelfState

    This function will be called when the manager issues an action to itself.

      • (dispatchProgram: Dispatch<ProgramAction>, dispatchSelf: Dispatch<SelfAction>, action: SelfAction, state: SelfState): SelfState
      • Parameters

        • dispatchProgram: Dispatch<ProgramAction>
        • dispatchSelf: Dispatch<SelfAction>
        • action: SelfAction
        • state: SelfState

        Returns SelfState

  • Readonly setup: (dispatchProgram: Dispatch<ProgramAction>, dispatchSelf: Dispatch<SelfAction>) => () => void

    This function will be called when initializing the effect manager.

      • (dispatchProgram: Dispatch<ProgramAction>, dispatchSelf: Dispatch<SelfAction>): () => void
      • Parameters

        Returns () => void

          • (): void
          • Returns void

Generated using TypeDoc