pyblish-base
pyblish-base copied to clipboard
Callbacks with name-less arguments
Goal
Enable more loosely coupled callbacks, where the signature doesn't have to match 1-1.
import pyblish.api
def on_my_signal(argument1, argument2):
print("%s, %s" % (argument1, argument2))
pyblish.api.register_callback("mySignal", on_my_signal)
pyblish.api.emit("mySignal", "arg1", True)
Motivation
When not including named arguments, we can alter the names in the implementation without breaking usage.
Current behavior
import pyblish.api
def on_my_signal(argument1, argument2):
print("%s, %s" % (argument1, argument2))
pyblish.api.register_callback("mySignal", on_my_signal)
pyblish.api.emit("mySignal", argument1="arg1", argument2=True)
Not entirely confident it is a better approach; but it would align with how signals and slots work in Qt which may make the mechanism more familiar overall.
Not entirely confident it is a better approach;
Don't know either:) Don't mind it though.