Ejemplo n.º 1
0
        public void IObservable_Subscribe()
        {
            // Arrange
            var observable = new MyObservable();
            var observer   = new MyObserver();

            // Act
            observable.Subscribe(observer);

            // Assert
        }
Ejemplo n.º 2
0
        public void AutoDetachObserver_ImplementISafeObserver()
        {
            var myObserver = Observer.Create <int>(i =>
            {
                i.Dump();
                if (i == 1)
                {
                    throw new Exception("triggered by observer");
                }
            }, ex => ex.Message.ToString(), () => "completed".Dump());
            var observer = new AutoDetachObserver <int>(myObserver);

            observer.SetResource(Disposable.Create(() => "obsrever exception i will clearnup by IDisposable Resource".Dump()));
            var observable = new MyObservable();

            observable.Subscribe(observer);
        }