-
-
Notifications
You must be signed in to change notification settings - Fork 187
Description
Thank you for redux-undo!
I'd like to group changes based not only on a comparison of prior/current action.type but also prior/current action.params.
Data model:
interface DraftState {
message: DraftMessageI
points: {
[url: string]: PointI
}
}
Stream of actions looks like:
{ type: 'draftPointCreate', params: { url: 'point1' } }
{ type: 'draftPointUpdate', params: { url: 'point1', content: 'h' } }
{ type: 'draftPointUpdate', params: { url: 'point1', content: 'he' } }
{ type: 'draftPointUpdate', params: { url: 'point1', content: 'hel' } }
{ type: 'draftPointUpdate', params: { url: 'point1', content: 'hell' } }
{ type: 'draftPointUpdate', params: { url: 'point1', content: 'hello' } }
{ type: 'draftPointCreate', params: { url: 'point2' } }
{ type: 'draftPointUpdate', params: { url: 'point2', content: 'w' } }
{ type: 'draftPointUpdate', params: { url: 'point2', content: 'wo' } }
{ type: 'draftPointUpdate', params: { url: 'point2', content: 'wor' } }
{ type: 'draftPointUpdate', params: { url: 'point2', content: 'worl' } }
{ type: 'draftPointUpdate', params: { url: 'point2', content: 'world' } }
I want to filter out changes which result from draftPointCreate actions since there's no need to store empty points in history.past. Additionally, I want to group changes which result from draftPointUpdate actions if and only if their action.params.url are the same. I tried this config:
export default undoable(draftReducer, {
filter: excludeAction('draftPointCreate'),
groupBy: groupByActionTypes('draftPointUpdate')
})
If the filtered draftPointCreate actions caused history.group to reset to null, this would work as intended. However, since #171 and #167, history.group is not modified on filtered actions (I agree that redux-undo current behavior makes sense).
Perhaps there's some other solution for my use case!
Thank you for your time!