Created
May 21, 2013 01:27
-
-
Save chrisallick/5616940 to your computer and use it in GitHub Desktop.
not happy with this, but lambdas are only a single line and you cannot pass anonymous functions in python :(
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from __future__ import print_function | |
events = {} | |
def fireEvent(event,msg): | |
events[event](msg) | |
def addEvent(event,type,func): | |
events[event] = func | |
def onCompass(msg): | |
print(msg) | |
addEvent("compass","string",onCompass) | |
fireEvent( "compass", "wazzsup" ) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment