ember-time-machine
ember-time-machine copied to clipboard
setProperties behaviour
We have a scenario where one action updates numerous properties on an object.
actions: {
changeItemType(item, type) {
setProperties(item, {
type,
options: options.findBy('type', type)
});
}
}
When we call item.undo()
we would expect all the attributes updates in the action to be reverted but it turns out that each attribute change is recorded as one undo.
Is there currently a way to achieve our requirement?
@offirgolan I had a play with your awesome code! And whipped up something that works https://github.com/offirgolan/ember-time-machine/pull/121
The new API is timemachine.beginChanges()
and timemachine.endChanges()
where you can make as many changes as you want but it will be undone with one step.
@offirgolan here's another approach where the undoStack
is a collection of changeSet
s which is essentially an array of Record
changes. A bit more neat I think 😉
https://github.com/offirgolan/ember-time-machine/pull/122