类 event.Publish


Defined in: jx.event.js.

类 概要
Constructor Attributes Constructor Name and Description
 
创建一个消息源发布者的类 Publish
方法概要
Method Attributes Method Name and Description
 
触发事件
 
注册观察者
 
注销观察者
类 详解
event.Publish()
功能:
创建一个消息源发布者的类 Publish
Jx().$package(function(J){
    var onMsg = new J.Publish();
 var funcA = function(option){
     alert(option);
 };
 // 注册一个事件的观察者
    onMsg.subscribe(funcA);
    var option = "demo";
    onMsg.deliver(option);
    onMsg.unsubscribe(funcA);
    onMsg.deliver(option);
    
};
返回:
{Object} 返回生成的消息源
方法详解
{Function} Publish#deliver(msg)
功能:
触发事件
参数:
{Mixed} msg
要注册的观察者
返回:
{Function} 返回结果

{Function} Publish#subscribe(func)
功能:
注册观察者
参数:
{Function} func
要注册的观察者
返回:
{Function} 返回结果

{Function} Publish#unsubscribe(func)
功能:
注销观察者
参数:
{Function} func
要注销的观察者
返回:
{Function} 返回结果