RestrictedSignal.connect

Indirect connection to an object.

Use this overload if you want to connect to an objects method which does not match the signal's signature. You can provide any delegate to do the parameter adaption, but make sure your delegates' context does not contain a reference to the target object, instead use the provided obj parameter, where the object passed to connect will be passed to your delegate. This is to make weak ref semantics possible, if your delegate contains a ref to obj, the object won't be freed as long as the connection remains.

Preconditions: obj and dg must not be null. dg's context must not be equal to obj.

  1. void connect(ClassType obj)
  2. void connect(ClassType obj, void delegate(ClassType obj, Args) dg)
    struct RestrictedSignal(Args...)
    void
    connect
    @trusted
    (
    ClassType
    )
    (
    ClassType obj
    ,
    void delegate(
    ClassType obj
    ,
    Args
    )
    dg
    )
    if (
    is(ClassType == class)
    )
    in { assert (obj); assert (dg); assert (cast(void*)obj !is dg.ptr); }
  3. void connect(void function(Args) fn)

Parameters

obj
Type: ClassType

The object to connect to. It will be passed to the delegate when the signal is emitted.

dg
Type: void delegate(
ClassType obj
,
Args
)

A wrapper delegate which takes care of calling some method of obj. It can do any kind of parameter adjustments necessary.

Meta