Lazy initialize object with Proxy Pattern
Sometimes, you want to lazy intialize an object such as websocket to make it’s only connected when needed, (virtual) proxy pattern can help.
Instead of initializing directly:
Using the Proxy:
Sometimes, you want to lazy intialize an object such as websocket to make it’s only connected when needed, (virtual) proxy pattern can help.
Instead of initializing directly:
Using the Proxy:
Understanding the basic differences between the 3 patterns.
Observer: the publisher must know and manage observers, observers will be attached to the specific publisher:
Pubsub: the publisher can publish an event without knowing who are the listeners, publisher and listeners communicate through the event channel:
Mediator: groups logic of domain that has indirect relationship between modules. We can use Pubsub
(not required, can use other patterns) to manage the workflow :