Last active
January 18, 2021 23:51
-
-
Save anddam/9ac1f252d1b9e861b0898e5badf5abf4 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
def Proxy: | |
"""Pass over a callback but get ahold of it | |
""" | |
def __init__(self, callback=None): | |
def augmented_call(*args, **kwargs): | |
self.callback_notification() | |
return callback(*args, **kwargs) if callback else None | |
self.someInstance = SomeClass(callback=augmented_call) | |
def callback_notification(self): | |
print("callback was invoked") |
This file contains hidden or 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
def Proxy: | |
"""Pass over a callback but get ahold of it | |
""" | |
def __init__(self, callback=None): | |
def augmented_call(*args, **kwargs): | |
self.callback_notification() | |
return callback(*args, **kwargs) | |
def empty_callback(*args, **kwargs): | |
self.callback_notification() | |
self.someInstance = SomeClass( | |
callback=augmented_call if callback else empty_callback) | |
def callback_notification(self): | |
print("callback was invoked") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment