模式来管理骨干的意见 [英] Pattern to manage views in backbone

查看:106
本文介绍了模式来管理骨干的意见的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

从GWT的到来,骨干似乎错过如何处理视图的生命周期内置的解决方案。 GWT中,每一个活动,这是或多或少相当于一个视图在骨干,由ActivityManager它调用调用onStart /的onStop上的活动管理,传递eventBus并且其中活性可以在要呈现的元件。在停止时,该ActivityManager将解除绑定活动已绑定到eventbus所有事件,并从DOM的观点。

Coming from GWT, Backbone seems to miss a built-in solution on how to handle the life-cycle of a view. In GWT, every activity, which is more or less the equivalent to a View in Backbone, is managed by an ActivityManager which calls onStart/onStop on the activity, passing the eventBus and the element where the Activity can be rendered in. On stop, the ActivityManager will unbind all events the activity has bind to the eventbus and remove the view from the DOM.

在骨干网,很容易绑定到模型的事件和集合,但你必须手动删除它们,没有共同的API方法,你会做到这一点。

In Backbone, it's easy to bind the events to model and collection but you have to remove them manually and there is no common api method where you will do this.

所以我在寻找如何管理意见,以确保没有中止或禁用,意见听取不必要的事件的最佳实践模式。

So I'm looking for best practice pattern on how to manage views to ensure no killed or disabled views are listening unnecessary to events.

推荐答案

木偶终于有了我在寻找的功能。

Seems Marionette finally has the functionality I'm looking for.

这篇关于模式来管理骨干的意见的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆