Advertisement
Guest User

Untitled

a guest
Apr 4th, 2020
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.67 KB | None | 0 0
  1. //first example: listeners are initialized directly in the controller
  2. public class ExampleControllerWithEvents
  3. {
  4.     void Initialize()
  5.     {
  6.         _eventBus.AddListener(firstEventType,FirstListener);
  7.         _eventBus.AddListener(secondEventType,SecondListener);
  8.     }
  9.  
  10.     void FirstListener(){...}
  11.     void SecondListener(){...}
  12. }
  13.  
  14. //second example: listeners are managed by additional layer
  15. public class Binder
  16. {
  17.     void Initialize()
  18.     {
  19.         _eventBus.AddListener(ExampleControllerFactory.Create().FirstListener);
  20.         _eventBus.AddListener(ExampleControllerFactory.Create().FirstListener);
  21.     }
  22. }
  23.  
  24. public class ExampleController
  25. {
  26.     void FirstListener(){...}
  27.     void SecondListener(){...}
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement