Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Are Qt's signals and slots a form of publish-subscribe?

I don't think I've seen this comparison anywhere, but would they be considered the same? If not, why not?

like image 339
jzepeda Avatar asked Mar 28 '12 07:03

jzepeda


2 Answers

They are very similar, but there is a little difference:

  • signals/slots implement the observer pattern, where the producer has a reference to its subscribers and is responsible of notifying them

  • the publish/subscribe paradigm inserts an additional mediator, i.e., the topic handler, which decouples producers and consumers (the producers does not know who will consume messages)

A main consequence is that in the p/s paradigm you can have multiple producers on the same topic.

This is (probably) the most cited article about p/s: The many faces of publish/subscribe

like image 82
tinito Avatar answered Sep 18 '22 06:09

tinito


publish subscribe is same as the signals and slots... check this...

http://en.wikipedia.org/wiki/Observer_pattern

http://doc.qt.nokia.com/qtmobility/publish-subscribe.html

like image 30
shofee Avatar answered Sep 22 '22 06:09

shofee