Pubsub facilitates the decoupling of components (callables, modules, packages) within an application. It does this by:
Allowing parts of the application to send messages to “the rest of the application” without having to know
if the messages will be handled:
perhaps the message will be ignored completely,
or handled by a many different parts of the application;
how the messages will be handled:
what will be done with the message and its contents;
in what order any given message will be sent to the rest of the application;
Allowing parts of the application to receive and handle messages from “the rest of the application” without having to know who sent the messages.
A listener is “a part of the application that wants to receive messages”. A listener subscribes to one or more topics. A sender is any part of the application that asks Pubsub to send a message of a given topic. The sender provides data, if any. Pubsub will send the message, including any data, to all listeners of the message’s topic.
Blinker docs和{a2}。在
就}而言,它们是一样的。不同之处在于他们如何去做:
Blinker
和{使用
Blinker
当您订阅一个信号时,您给出信号的名称,当您激活该信号时,您将传递激活对象。在使用
PubSub
订阅侦听器时,您将给出名称(与Blinker
相同),但当您通知侦听器时,您直接将数据作为关键字参数传递。由于传递数据的关键字参数方法,可以使用PubSub
进行更多的安全检查。在就个人而言,我会选择}当然也有一席之地。在
Signals
,因为它更符合我的思维方式,但是{这可能会明确Pubsub与信号的关系:http://pubsub.sourceforge.net/apidocs/concepts.html
相关问题 更多 >
编程相关推荐