The Callback Function Signature
The main difference between Payload Data and Parameters has to do with the binding function’s signature.
The binding function/callback signature has to match our delegate parameters PLUS desired extra parameters(payload data).
- Required in EVERY callback function that wishes to bind to our delegate.
- Defined when delegate is created with DECLARE_DELEGATE or any similar macro.
- If you want every Bound function to receive data/argument as part of it’s signature, you include it as a delegate Parameter.
Delegate Payload Data
- Required ONLY IN callback functions that wish to receive extra parameters, in addition to the required parameters above, from our delegate when it broadcasts/executes.
- Defined when delegate is bound (bind is called) to our function.
Payload Data Example Use Case
You already have a function that takes in 8 parameters and it’s being used in other parts of your code.
The first two arguments of the function match our new delegate function parameters. So:
We already have a function that takes in 8 arguments and we want to bind it to a delegate that passes only 2 parameters.
The solution is to pass the rest of the 6 arguments required by the function as Payload data at BIND time.