public void Test5() { var classicHotlink = new ClassicHotlink <string>(); void OnNext(string value) { Console.Write(value); } void OnError(Exception exception) { Console.WriteLine("exception, "); } void OnCompleted() { Console.Write("sequence completed, "); } var observable = classicHotlink.AsObservable(); observable.Subscribe(OnNext, OnError, OnCompleted); classicHotlink.Emit("1, "); classicHotlink.Emit("2, "); classicHotlink.Emit("3, "); classicHotlink.Emit("der gejid!, "); classicHotlink.Complete(); }
public void Test6_WithReplaySubject(string description, bool fail) { var classicHotlink = new ClassicHotlink <string>(); void OnNext(string value) { Console.WriteLine("a: " + value); } void OnNext2(string value) { Console.WriteLine("b: " + value); } void OnError2(Exception exception) { Console.WriteLine("b: " + exception); } void OnCompleted2() { Console.WriteLine("b: sequence completed"); } var observable = classicHotlink.AsObservable(); var replaySubject = new ReplaySubject <string>(); observable.Subscribe(replaySubject); var subscription1 = replaySubject.Subscribe(OnNext, _ => { }, () => { }); classicHotlink.Emit("1"); subscription1.Dispose(); classicHotlink.Emit("not lost!"); var subscription2 = replaySubject.Subscribe(OnNext2, OnError2, OnCompleted2); classicHotlink.Emit("2"); subscription2.Dispose(); if (fail) { classicHotlink.Fail(); } classicHotlink.Emit("3 - no observer"); if (!fail) { classicHotlink.Complete(); } replaySubject.Subscribe(OnNext2, OnError2, OnCompleted2); }
public void Test6(string description, bool fail) { var classicHotlink = new ClassicHotlink <string>(); void OnNext(string value) { Console.Write("a: " + value); } void OnNext2(string value) { Console.Write("b: " + value); } void OnError2(Exception exception) { Console.Write("b: " + exception + ", "); } void OnCompleted2() { Console.Write("b: sequence completed, "); } var observable = classicHotlink.AsConnectableObservable(); var subscription = observable.Subscribe(OnNext, _ => { }, () => { }); observable.Subscribe(OnNext2, OnError2, OnCompleted2); var connection = observable.Connect(); classicHotlink.Emit("1, "); connection.Dispose(); classicHotlink.Emit("lost, "); observable.Connect(); classicHotlink.Emit("2, "); subscription.Dispose(); if (fail) { classicHotlink.Fail(); } classicHotlink.Emit("3, "); if (!fail) { classicHotlink.Complete(); } }