JSPM

point-reducer-builder

0.4.4
    • ESM via JSPM
    • ES Module Entrypoint
    • Export Map
    • Keywords
    • License
    • Repository URL
    • TypeScript Types
    • README
    • Created
    • Published
    • Downloads 4
    • Score
      100M100P100Q44747F
    • License MIT

    Build Reducer by composing actions

    Package Exports

    • point-reducer-builder

    This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (point-reducer-builder) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

    Readme

    Reducer Builder for Point One or Redux

    Build Status codecov.io

    When you use Point One or Redux many of your reducers have many code with closer functionality. But you put it each time and sometimes you copy it to new places and forget to change something.

    Just look at your code and count places where you:

    1. Find Index of element in array
    2. Replace/Update/Remove elements from array

    And after this look at this code:

    let todoReducer = event(
      /TODO_/,
      select(
        'users',
        event(
          'TODO_ADD',
          project(
            e => e.data,
            select('id', append())
          )
        ),
        event(
          'TODO_UPDATE',
          project(
            e => e.data,
            select('id', update())
          )
        ),
        event(
          'TODO_REMOVE',
          project(e => e.data, remove('id'))
        ),
        event(
          'TODO_DONE',
          project(
            e => e.data,
            select(
              'id',
              set('done', true)
            )
          )
        )
      )
    )