开发者

Delete models and collections

开发者 https://www.devze.com 2023-04-10 15:18 出处:网络
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 do

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?


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消