0

Is there some doco on IAutoSubscriptionService. How do I use using (ESP.GetEcoService().StartSubscribe(subscriber)) to trigger an event when an object changes. That is for any attribute of an object.

Steve.Au
  • 31
  • 5

1 Answers1

0

The StartSubscribe gives a IDisposable context back and it is typically used like this:

using (theAutoSubscriptionService.StartSubscribe(subscriber))
{
     arbitrary c# code accessing model elements 
     - all access will be added to subscription! 
     A thing of beauty really!
}

When something later change - the ISubscriber.Receive will fire. For adhoc usage consider the EventSubscriber class

Hans Karlsen
  • 2,275
  • 1
  • 15
  • 15
  • What is the purpose of bool ISubscriber.IsAlive() and int ISubscriber.HashKey – Steve.Au Nov 15 '22 at 02:51
  • Subscribers are kept as weakreferences to avoid locking GC - the IsAlive of the ISubscriber is the weakreference.IsAlive exposed - if false we dont notify it - and we clean if from the publishers list when discovered – Hans Karlsen Nov 15 '22 at 13:57
  • Publishers (anything subscribable) can potentially get a lot of subscribers - we keep them in a dictionary on their hashkey - since they are weakreferences we cannot trust to use its existence in a hashlist – Hans Karlsen Nov 15 '22 at 14:01