Design-Patterns
Design-Patterns copied to clipboard
Observer with subscription
You can notify for all observers but some observers can subscribed and unsuscribed in any moment, this is very common in Android because Screens are subscribed and unsuscribed every time.
Example output:
Value: First request a value and updates
Value: Third request a value
Notify: Toni
First updated: Toni
Second updated: Toni
Notify: Cotel
First updated: Cotel
Second updated: Cotel
Unregister all
Notify: Fran
Nothing happens
Register first and second
Notify: That's all
First updated: That's all
Second updated: That's all