|
|
|
|
|
by ville
4988 days ago
|
|
Could someone give a practical example of a use case for this? This is probably useful for some typical problems in Backbone applications but not something I knew I would need (having built a couple of non-trivial Backbone apps). |
|
- list of folders
- contents of a given folder
- contents of a thread
- contents of a message
- compose message
- profile settings
- ...
In a typical MVC app, the 'enter' method of each state would set up the appropriate models, views and controllers, and the 'exit' method would do the corresponding teardown / cleanup. You could tie this to the history API (or history.js) to support URL linking and navigation.
But states can mean anything you want as long as only one of them can be active at any time in a given context (StateManager). In a Vim implementation you could manage the normal / insert / visual editing modes using States. In a space shooter game, you could have the player spaceship be in normal, shielded, dead, etc states.
The link to Backbone is extremely thin and basically limited to using Backbone's event system to trigger state change events.