2 ms·
This was a nice thing in the example from Raganwald's blog post. The `transitionsTo` decorator: function transitionsTo (stateName, fn) { return function
by Jtsummers 9y ago
This was a nice thing in the example from Raganwald's blog post. The `transitionsTo` decorator:
function transitionsTo (stateName, fn) {
return function (...args) {
const returnValue = fn.apply(this, args);
this[STATE] = this[STATES][stateName];
return returnValue;
};
}
By separating the state transitions from the state actions in this way it allows the functional components to be reused much more easily. You can construct the miniplayer using only the states you need with only the transitions you need (rather than obscured/hidden capabilities).
- cbetti 9y agoThis is a nice approach, thank you for pointing it out. I'd argue that you are building a separate state machine for the two players, but there is some reuse possible in this approach.