public void Run(IObservable <TFirst> first, IObservable <TSecond> second) { var fstO = new FirstObserver(this); var sndO = new SecondObserver(this); Disposable.SetSingle(ref _secondDisposable, second.SubscribeSafe(sndO)); SetUpstream(first.SubscribeSafe(fstO)); }
public void Test1() { var subject = new Subject(); var firstObserver = new FirstObserver(); var secondObserver = new SecondObserver(); firstObserver.Subscribe(subject); secondObserver.Subscribe(subject); subject.Notify("Something happened"); }
public void Run(IObservable <TFirst> first, IObservable <TSecond> second) { var fstO = new FirstObserver(this); var sndO = new SecondObserver(this); fstO.SetOther(sndO); sndO.SetOther(fstO); _firstDisposable.Disposable = first.SubscribeSafe(fstO); _secondDisposable.Disposable = second.SubscribeSafe(sndO); }
protected override IEnumerable <ISubscription> OnSubscribe() { var firstObserver = new FirstObserver(this); var otherObserver = new OtherObserver(this); var firstSubscription = Params._source.Subscribe(firstObserver); _otherSubscription = Params._other.Subscribe(otherObserver); otherObserver.Subscription = _otherSubscription; return(new[] { firstSubscription, _otherSubscription }); }
public _(Func <TFirst, TSecond, TResult> resultSelector, IObserver <TResult> observer) : base(observer) { _gate = new object(); _firstObserver = new FirstObserver(this); _secondObserver = new SecondObserver(this); _firstObserver.SetOther(_secondObserver); _secondObserver.SetOther(_firstObserver); _resultSelector = resultSelector; }
public void Run(IObservable <TFirst> first, IObservable <TSecond> second) { _gate = new object(); var fstO = new FirstObserver(this); var sndO = new SecondObserver(this); fstO.Other = sndO; sndO.Other = fstO; Disposable.SetSingle(ref _firstDisposable, first.SubscribeSafe(fstO)); Disposable.SetSingle(ref _secondDisposable, second.SubscribeSafe(sndO)); }
static void Main(string[] args) { Console.WriteLine("Hello World!"); ISubject subject = new Subject(); IObserver observer1 = new FirstObserver(subject); IObserver observer2 = new SecondObserver(subject); subject.AddObserver(observer1); subject.AddObserver(observer2); subject.HaveSomeTechLogic(); subject.RemoveObserver(observer1); subject.HaveSomeTechLogic(); }
protected override IEnumerable <ISubscription> OnSubscribe() { _firstSubscription = new SingleAssignmentSubscription(); var otherSubscription = new SingleAssignmentSubscription(); var firstObserver = new FirstObserver(this, _firstSubscription); _otherObserver = new OtherObserver(this, firstObserver, otherSubscription); _firstSubscription.Subscription = Params._source.Subscribe(firstObserver); otherSubscription.Subscription = Params._other.Take(1).Subscribe(_otherObserver); return(new[] { _firstSubscription, otherSubscription }); }
public IDisposable Run(IObservable <TFirst> first, IObservable <TSecond> second) { _gate = new object(); _latestGate = new object(); var sndSubscription = new SingleAssignmentDisposable(); var fstO = new FirstObserver(this); var sndO = new SecondObserver(this, sndSubscription); sndSubscription.Disposable = second.SubscribeSafe(sndO); var fstSubscription = first.SubscribeSafe(fstO); return(StableCompositeDisposable.Create(fstSubscription, sndSubscription)); }
public override void Run() { var someObservable = new SomeObservable(); var firstObserver = new FirstObserver(); var secondObserver = new SecondObserver(); someObservable.DoSomeAction(800); Console.WriteLine("Add FirstObserver"); _firstCancelation = someObservable.Subscribe(firstObserver); Console.WriteLine("Add SecondObserver"); someObservable.Subscribe(secondObserver); Console.WriteLine("Do some action in Observable twice"); someObservable.DoSomeAction(100); someObservable.DoSomeAction(200); Console.WriteLine("Unsubscribe FirstObserver and Do some action in Observable"); _firstCancelation.Dispose(); someObservable.DoSomeAction(300); Console.WriteLine("Cancel notify"); someObservable.StopNotify(); }
public SecondObserver(_ parent) { _parent = parent; _queue = new Queue <TSecond>(); _other = default !; // NB: Will be set by SetOther.
public SecondObserver(_ parent) { _parent = parent; _other = default !; // NB: Will be set by SetOther.
public OtherObserver(_ skipUntilOperator, FirstObserver firstObserver, ISubscription subscription) { _skipUntilObserver = skipUntilOperator; _firstObserver = firstObserver; _subscription = subscription; }