Function dis

Redux like state reducer within diInit callback

Call it with value for state reducing

Call it without arguments for getting state

const sum = dis((sum, n) => sum + n, 0)
sum(5)
sum(5)
sum() // 10
  • Type Parameters

    • P
    • S

    Parameters

    • fn: ((state: S, payload: P) => S)
        • (state, payload): S
        • Parameters

          • state: S
          • payload: P

          Returns S

    • defaultState: S

    Returns ((this: unknown, payload?: P) => S)

      • (this, payload?): S
      • Parameters

        • this: unknown
        • Optionalpayload: P

        Returns S