Package Exports
- knockout-undoredo
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (knockout-undoredo) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
Knockout Undo-Redo
This library provides a generic way of history-management for knockout observables.
Install
$> npm install knockout-undoredo
Usage
import ko from 'knockout';
import UndoManager from 'knockout-undoredo';
class ViewModel {
constructor() {
this.name = ko.observable('Kai');
this.message = ko.pureComputed(() => `Hello ${this.name()}, how are you`);
}
}
const vm = new ViewModel();
const undomanager = new UndoManager(vm);
ko.applyBindings(vm);
// ...later
console.log(vm.message()); // 'Hello Kai';
vm.name('Rita');
console.log(vm.message()); // 'Hello Rita';
undomanager.undo();
console.log(vm.message()); // 'Hello Kai';
undomanager.redo();
console.log(vm.message()); // 'Hello Rita';