hiebj / stately

elegant, type-safe state management
2 stars 1 forks source link

feature: ID reducer #11

Open hiebj opened 5 years ago

hiebj commented 5 years ago

box(key, reducer) takes a reducer and maps it to the given key.

Another convenience reducer, id(reducer, getId: (action) => id) could take a reducer and, using the given getId, map actions matched by that reducer into an id derived from the action.

This is very similar to "lens", but there's really only one use case where lens makes sense, so an actual lens implementation would be overkill.