Publisher | Super Maxim |
---|---|
File size | 1.13MB |
Number of files | 48 |
Latest version | 1.0.1 |
Latest release date | 2021-08-17 07:53:15 |
First release date | 2020-07-14 09:45:11 |
Supported Unity versions | 2018.4.2 or higher |
Pub\Sub Messenger is a Lightweight, Open Source Library for Unity.
This library will provide a Pub\Sub Mechanism that is a part of SOLID principles in programming.
PROBLEMS IN GAMES
* Wiring the Parts with Events – Tightly Coupled and may cause Memory Leak problems. The Publisher and the Subscriber have to know of each other, and a Subscriber can’t be collected by the GC if it’s connected with the Publisher with strong event reference.
* Using Unity Event Routing – Although Unity Event Routing is a very good feature, it is a Unity Specific Solution and we need a generic one. Also, we cannot use it everywhere even if the project is in Unity.
* Dependency - In commonly used C# events or delegates, classes are “familiar” with each other and this prevents good modularity. This is NOT following SOLID Principles and Objects are not Encapsulated.
THE SOLUTION
* Pub\Sub Messenger - Container for Events that allows Decoupling of Publishers and Subscribers so they can evolve independently. This Decoupling is useful in Modularised Applications because new modules can be added that respond to events defined by the Shell or, more likely, other modules. All events have a Weak Reference and invocation can be done Async or Sync way.
* Payloads - Instead of passing objects or modules, pass small Payloads (Data/Messages) that are relevant for the specific cases/events.
* Encapsulation - Classes/Modules will not be “familiar” with each other, this will allow better encapsulation and less dependencies.
* Weak Reference - In case of subscriber’s destruction, it will be removed automatically from Messenger’s list, since it was referenced via Weak Reference.
* SOLID Principles - Pub/Sub can be a great pattern in combination with Dependency Injection (DP) and with Inversion of Control (IoC), both part of SOLID Principles.
Supported Platforms: Android, iOS, Windows, Mac, Linux, WebGL
Supported Unity Versions: 2017.x, 2018.x, 2019.x
Sources