schollii / pypubsub

A Python publish-subcribe library (moved here from SourceForge.net where I had it for many years)
194 stars 29 forks source link

Can't use closure function for subscribe callback function #50

Open windslinux opened 4 years ago

windslinux commented 4 years ago

from pubsub import pub

def localCall(func): def real_func(data): print("In real function : {}".format(data)) func(data) return real_func

def localUpdate(data): print("In local update")

pub.subscribe(localCall(localUpdate), "update") pub.sendMessage("update", data="updateUI")

In the example above, the function localUpdate can't be called. I have no idea why the closure function can't be called?