Skip to content

Commit

Permalink
fix(interceptors): update undo handling to support history cursors
Browse files Browse the repository at this point in the history
  • Loading branch information
postspectacular committed Apr 16, 2018
1 parent b856fec commit 9a83d4e
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions packages/interceptors/src/event-bus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -582,16 +582,18 @@ export class EventBus extends StatelessEventBus implements
({ [FX_STATE]: setIn(state, path, val) }),
[api.EV_UPDATE_VALUE]: (state, [_, [path, fn, ...args]]) =>
({ [FX_STATE]: updateIn(state, path, fn, ...args) }),
[api.EV_UNDO]: (_, [__, id = "history"], ___, ctx) => {
[api.EV_UNDO]: (_, [__, id = "history"], bus, ctx) => {
if (implementsFunction(ctx[id], "undo")) {
return { [FX_STATE]: ctx[id].undo() }
ctx[id].undo();
return { [FX_STATE]: bus.state.deref() };
} else {
console.warn("no history in context");
}
},
[api.EV_REDO]: (_, [__, id = "history"], ___, ctx) => {
[api.EV_REDO]: (_, [__, id = "history"], bus, ctx) => {
if (implementsFunction(ctx[id], "redo")) {
return { [FX_STATE]: ctx[id].redo() }
ctx[id].redo();
return { [FX_STATE]: bus.state.deref() };
} else {
console.warn("no history in context");
}
Expand Down

0 comments on commit 9a83d4e

Please sign in to comment.