Navigating through history
// app.ts
import { inject } from 'aurelia-framework';
import { Store, jump, StateHistory } from 'aurelia-store';
import { State } from './state';
@inject(Store)
export class App {
private state: StateHistory<State>;
constructor(private store: Store<StateHistory<State>>) {
this.store.state.subscribe(
(state: StateHistory<State>) => (this.state = state)
);
}
undo() {
this.store.dispatch(jump, -1); // Go back one step in history
}
redo() {
this.store.dispatch(jump, 1); // Go forward one step in history
}
}Limiting the Number of History Items
Last updated
Was this helpful?