Live data from Hacker News

Crashlytics Labs announces the release of Backbone.StateManager

crashlytics.com

11–16 of 16 posts

Re: Crashlytics Labs announces the release of Backbone.StateManager

#11
post #10
post #8

Earlier quoted context omitted.

Useful to manage parts of your application (or the whole thing) as state machines. For example, a simple email app might have top-level states such as: - 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' m…

I'm very much a noob when it comes to Backbone, but isn't the states you described a use case for the built in router already included in Backbone?

That's treating the application as if it were completely stateless, and mucks with browser history. A good example of when to use state vs. a route is on a delete. If I route to a delete, for example, then it might fire again when I hit my 'back' button, which is obviously a bad idea.

Derick Bailey has a good article on it here: http://lostechies.com/derickbailey/2011/08/03/stop-using-bac...

Re: Crashlytics Labs announces the release of Backbone.StateManager

#12
post #11
post #10

Earlier quoted context omitted.

I'm very much a noob when it comes to Backbone, but isn't the states you described a use case for the built in router already included in Backbone?

That's treating the application as if it were completely stateless, and mucks with browser history. A good example of when to use state vs. a route is on a delete. If I route to a delete, for example, then it might fire again when I hit my 'back' button, which is obviously a bad idea. Derick Bailey has a good article on it here: http://lostechies.com/derickbailey/2011/08/03/stop-using-bac...

awesome, thanks!

Re: Crashlytics Labs announces the release of Backbone.StateManager

#13
post #2

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).

@ZackMaril points to a blog post where he discusses the potential benefits of a Backbone.Router that could provide state awareness to other application objects such as models. Scroll down to the Eidetic backbone section to read more. http://zacharymaril.com/blog/2012/07/10/ideas-about-future-o...

Yep! It looks like if you hooked this up to the router with serialization function, you could embed state directly into the url without too much effort.

Re: Crashlytics Labs announces the release of Backbone.StateManager

#14
Seems to me like this is reinventing parts of ember.js on top of Backbone. That's neat but when my apps need this sort of behavior I'm willing to be they will also need solutions to other common problems and I'd rather not reassemble a large framework out of disparate pieces to get that level of functionality. When do you decide that you have so many layers on top of Backbone that you have a custom stack no one else will understand?

Re: Crashlytics Labs announces the release of Backbone.StateManager

#16
post #10
post #8

Earlier quoted context omitted.

Useful to manage parts of your application (or the whole thing) as state machines. For example, a simple email app might have top-level states such as: - 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' m…

I'm very much a noob when it comes to Backbone, but isn't the states you described a use case for the built in router already included in Backbone?

You could use Backbone's routes to manage top-level app states if there is a 1:1 mapping between states and routes, your app's states are relatively simple, and you don't need any special handling of transitions. As bmelton describes, that case is not as common or obvious as one might think.

In general, I'd always encourage any non-trivial app to treat states and routes/history separately.

Post reply on HN