CloudCoders / Design-Patterns

Project for learning and discuss about design patterns
16 stars 1 forks source link

Observer with subscription #55

Open tonilopezmr opened 7 years ago

tonilopezmr commented 7 years ago

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

Coverage:

screen shot 2017-06-03 at 13 18 20