Ext JS中的事件驱动编程 [英] Event driven programming in Ext JS

查看:95
本文介绍了Ext JS中的事件驱动编程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个应用程序,该应用程序会将来自不同插件的不同窗口小部件加载到主机中,并且彼此之间不认识.因此,我想使用EDP,并在一个小部件中引发一个事件(例如,UserDeleted),在另一个小部件中,引发该事件(著名的发布者/订阅者,或者让我们获得更具体的观察者模式).

在jQuery中,我使用trigger()和bind()方法来完成此任务.但是,我在Ext JS中找不到任何等效的东西.我想念什么吗?还是有其他模式可以在Ext JS中创建松耦合的UI小部件?

解决方案

如果您的小部件彼此之间不认识,则需要使用中介模式.

似乎 Ext.util.Observable 是什么您正在寻找.

I'm working on an application where different widgets from different plugins would be loaded into a host, and they don't know of each other. So I want to use EDP and in one widget raise an event (for example, UserDeleted) and in another widget, subscribe to that event (the famous publisher/subscriber, or let's get more specific, observer pattern).

In jQuery I use trigger() and bind() methods to accomplish this. However, I'm not able to find anything equivalent in Ext JS. Am I missing something? Or is there any other pattern to create loosely coupled UI widgets in Ext JS?

解决方案

If your widgets don't know about each other, you need to use the mediator pattern.

And it seems that Ext.util.Observable is what you're looking for.

这篇关于Ext JS中的事件驱动编程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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