pyblish-base icon indicating copy to clipboard operation
pyblish-base copied to clipboard

Callbacks with name-less arguments

Open mottosso opened this issue 9 years ago • 1 comments

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.

mottosso avatar Feb 08 '16 07:02 mottosso

Not entirely confident it is a better approach;

Don't know either:) Don't mind it though.

tokejepsen avatar Feb 08 '16 08:02 tokejepsen