11.4.1 • Published 6 months ago

fl-redux-utils v11.4.1

Weekly downloads
8
License
MIT
Repository
github
Last release
6 months ago

Boilerplate and helper functions for redux that can be shared amongst FounderLab apps

createGroupByReducer

Use this to take an action parsed by responseParser and generate a map of lists of model ids grouped by a given key

e.g. here the byLesson property of the state will be a list of file ids that share a lessonId

const byLesson = createGroupByReducer([TYPES.FILE_LOAD + '_SUCCESS'], file => file.lessonId)

...

/*
  state will look like: 
  {
    ...
    byLesson: {
      123: {
        id: 1,
        lessonId: 123
      },
      456: {
        id: 2,
        lessonId: 456
      },
    },
  }
*/
export default function fileReducer(state=defaultState, action={}) {

  switch (action.type) {
    ...

    case TYPES.FILE_LOAD + '_SUCCESS':
      return = state.mergeDeep({
        loading: false,
        error: null,
        byLesson: byLesson(state.get('byLesson'), action),
      })

    ...
  }
}

createGroupByReducer

Use this to take an action parsed by responseParser and generate a list of model ids grouped by a given key

e.g. here the byLesson property of the state will be a list of file ids that share a lessonId

const byLesson = createGroupByReducer([TYPES.FILE_LOAD + '_SUCCESS'], file => file.lessonId)

...

export default function fileReducer(state=defaultState, action={}) {

  switch (action.type) {
    ...

    case TYPES.FILE_LOAD + '_SUCCESS':
      return = state.mergeDeep({
        loading: false,
        error: null,
        byLesson: byLesson(state.get('byLesson'), action),
      })

    ...
  }
}
11.4.1

6 months ago

11.0.0

1 year ago

10.1.0

1 year ago

10.1.1

1 year ago

10.0.0

1 year ago

9.0.0-rc.6

2 years ago

9.0.0-rc.4

2 years ago

9.0.0-rc.2

2 years ago

9.0.0

2 years ago

7.8.0

2 years ago

7.6.22

3 years ago

7.6.15

3 years ago

7.6.16

3 years ago

7.6.14

3 years ago

7.4.17

3 years ago

7.4.13

4 years ago

7.4.5

4 years ago

7.4.4

4 years ago

7.4.3

4 years ago

7.4.1

4 years ago

7.4.0

4 years ago

7.3.4

4 years ago

7.3.3

4 years ago

7.3.1

4 years ago

7.2.4

4 years ago

7.2.3

4 years ago

7.2.2

4 years ago

7.2.1

4 years ago

7.2.0

4 years ago

7.1.3

4 years ago

7.0.23

5 years ago

7.0.17

5 years ago

7.0.8

5 years ago

7.0.6

5 years ago

7.0.0

5 years ago

6.18.2

5 years ago

6.16.0

5 years ago

6.11.0

5 years ago

6.9.1

5 years ago

6.7.6

6 years ago

6.0.1

6 years ago

6.0.0

6 years ago

5.0.3

6 years ago

5.0.1

6 years ago

5.0.0

6 years ago

4.0.16

6 years ago

1.0.0

7 years ago

1.0.0-alpha.7

7 years ago

1.0.0-alpha.6

7 years ago

1.0.0-alpha.5

7 years ago

1.0.0-alpha.4

7 years ago

1.0.0-alpha.3

7 years ago

1.0.0-alpha.2

7 years ago

1.0.0-alpha.1

7 years ago

0.5.0

7 years ago

0.4.3

7 years ago

0.4.2

7 years ago

0.4.1

7 years ago

0.4.0

7 years ago

0.3.1

7 years ago

0.3.0

7 years ago

0.2.2

8 years ago

0.2.1

8 years ago

0.2.0

8 years ago

0.1.3

8 years ago

0.1.2

8 years ago

0.1.1

8 years ago

0.1.0

8 years ago