vendredi 3 janvier 2020

Any design pattern to re-subscribe if Model is replaced?

I have a piece of UI which should reflect changes on Device object by using ViewModel (I hope the picture makes it clear). Now the Device can be changed at any time and replaced with another device object. So currently the ViewModel subscribes on current Device object in constructor, then subscribes to device manager to receive notifications on device change, then on this notification it removes subscriptions on old device and reinstalls subscriptions on the object. Looks quite awkward to me.

Is there any pattern for this situation?

Model

Aucun commentaire:

Enregistrer un commentaire