Skip to content

Commit

Permalink
add: unsubscribe method for Subscriber class
Browse files Browse the repository at this point in the history
  • Loading branch information
fkromer committed Mar 6, 2016
1 parent a73a054 commit e9619ad
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions publish_subscribe.py
Expand Up @@ -48,6 +48,9 @@ def __init__(self, name, msg_center):
def subscribe(self, msg):
self.provider.subscribe(msg, self)

def unsubscribe(self, msg):
self.provider.unsubscribe(msg, self)

def run(self, msg):
print("{} got {}".format(self.name, msg))

Expand All @@ -63,6 +66,9 @@ def main():
jack.subscribe("music")
gee = Subscriber("gee", message_center)
gee.subscribe("movie")
vani = Subscriber("vani", message_center)
vani.subscribe("movie")
vani.unsubscribe("movie")

fftv.publish("cartoon")
fftv.publish("music")
Expand Down

0 comments on commit e9619ad

Please sign in to comment.