boom
boom

Reputation: 11686

Delete models and collections

Using Backbone.js:

When a user logs out is it normal to delete a bunch of models and collections?

That's what I plan to do in my application to prevent zombie data/bindings but I dont know if it's the best way to handle things.

If this is a good practice should I just call delete this on cleanup?

Upvotes: 0

Views: 88

Answers (1)

Derick Bailey
Derick Bailey

Reputation: 72868

the zombies you need to worry about come from binding to events. i wrote a post about this from the perspective of views: http://lostechies.com/derickbailey/2011/09/15/zombies-run-managing-page-transitions-in-backbone-apps/

in your case with models, you should do the unbinding first and then delete the models and collections you don't need. calling delete whatever is the best way to ensure that things are truly gone. be sure to unbind from your model and collection events first, or you'll end up with bindings that point to undefined and cause exceptions.

Upvotes: 1

Related Questions