unirakun / k-redux-factory

Factory of Redux reducers and their associated actions and selectors.
MIT License
18 stars 4 forks source link

Add the possibility to pass an array to all `keyValue` actions #103

Closed EmrysMyrddin closed 6 years ago

EmrysMyrddin commented 6 years ago

Problem

We often have to update every values in a keyValue store. But with the current API, it can lead to a huge number of dispatched actions.

Proposition

I propose to make update, addOrUpdate and replace action polymorphic on their argument, allowing to pass an instance or an array of instances.

Example

import { keyValue } from 'k-redux-factory'

const store = keyValue({ key: 'id' })

store.addOrUpdate([
  { id: 1, value: '1' },
  { id: 2, value: '2' },
  { id: 3, value: '3' },
])
fabienjuif commented 6 years ago

This is a nice catch.

And as you said in your PR, we will maybe hit a performance issue. That's why I opened #108 .

Can you review this PR, and next steps associated. I would like to know your opinion about this.