Beispiel #1
0
 /// <summary>
 /// Subscribes our inbox to another process state publish stream.
 /// When a process state updates at the end of its message loop it announces it arrives in our inbox.
 /// You should use this for notification only.  Never modify the state object belonging to a process.
 /// Best practice is to make the state type immutable.
 /// </summary>
 /// <remarks>
 /// The process can publish any number of types, any published messages not of type T will be ignored.
 /// This should be used from within a process' message loop only
 /// </remarks>
 /// <returns>IObservable T</returns>
 public static Unit subscribeState <T>(ProcessId pid) =>
 InMessageLoop
         ? ActorContext.SelfProcess.Actor.AddSubscription(
     pid,
     ActorContext.ObserveState <T>(pid).Subscribe(x => tell(Self, x, pid)))
         : raiseUseInMsgLoopOnlyException <Unit>(nameof(subscribeState));
Beispiel #2
0
 /// <summary>
 /// Get an IObservable for a process's state stream.  When a process state updates at the end of its
 /// message loop it announces it on the stream returned from this method.  You should use this for
 /// notification only.  Never modify the state object belonging to a process.  Best practice is to make
 /// the state type immutable.
 /// </summary>
 /// <remarks>
 /// The process can publish any number of types, any published messages not of type T will be ignored.
 ///
 /// Because this call is asychronous it could allow access to the message loop, therefore
 /// you can't call it from within a process message loop.
 /// </remarks>
 /// <returns>IObservable T</returns>
 public static IObservable <T> observeState <T>(ProcessId pid) =>
 InMessageLoop
         ? raiseDontUseInMessageLoopException <IObservable <T> >(nameof(observeState))
         : ActorContext.ObserveState <T>(pid);