Temporal Composability
Undo / Redo in angular with promises and the command pattern
Image by Gossins: Flow of Time
Undo / Redo
Native apps (including browser) support undo
Web apps and Mobile apps do not Power users produce more errors than
consumers Power users on a computer with native app What happens when a power user uses a
web app?
Power User
I want to be able to build a collection I want to be able to undo a price change
without having to remember which price I destroyed.
Use Case
Sets all items to 222% margin
function
x f(x)
invertable
x f(x)
f-1(f(x))
State Machine
Dual Transitions
Command Pattern
Double Stack
Double Stack
asdf
Creating a collection ID is returned asynchronously as a promise ID not specified until after creation but
needed for deletion
Discontinuity
*Each function has the result of its inverse as input
Promises and double closure
msg
Results Promise
Context
Arguments
Function
Results Promise
inversemsg
Promises
F -> $q(f) - Function that generates a promise (reuse allows for unlimited undo/redo)
Asynchronous actions are handled (composition)
Anything can undo/redo if providing 2 functions
User messaging for current state of undo/redo
Reusablility & Composiblity
Answers & Questions