-
-
Save geoffreyd/63c790db4883498578ca to your computer and use it in GitHub Desktop.
StateChart Observer Example Usage
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
rootState: Ki.State.design({ | |
initialSubstate: 'loading', | |
loading: Ki.State.design({ | |
enterState: function() { | |
var controller = App.ticketsController; | |
this._observer = this.addStatechartObserver(controller, 'status', 'statusChanged'); | |
controller.set('content', App.store.find(App.TICKET_QUERY)); | |
}, | |
statusChanged: function(target, key, revision) { | |
if (target === App.ticketsController && key === 'status') { | |
if (target.get(key) === SC.Record.READY_CLEAN) this.gotoState('idle') ; | |
// else ignore any other status changes | |
} | |
}, | |
exitState: function() { | |
this.removeStatechartObserver(App.ticketsController, 'status', this._observer) ; | |
this._observer = null ; | |
} | |
}), | |
idle:Ki.State.design({ | |
enterState: function() { | |
console.log('idle'); | |
} | |
}) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment