Callbacks vs. Cloures - toant-dev/toandev.github.io GitHub Wiki

https://fxstudio.dev/delegates-vs-closure-callback/

Callback base pattern: Delegate Pattern, Closure Pattern

WHATS

  1. Breaking the retain cycle
  2. One to many relationships
  3. Datasources
  4. Scalability
  5. Enforcing the contract

CHOOSE

  • You have a single callback => Closure
  • Your callbacks are more like notifications => Delegate
  • You need to become the delegate to multiple instances => Closure
  • Your delegate is actually a datasource => Delegate
  • Your have many callbacks, and they might change in the future => Delegate