Ejemplo n.º 1
0
        // Install-Package System.Reactive
        public static void SubjectTest()
        {
            var source = new Subject <string>();

            source.OnNext("Hello");
            source.OnNext("World");

            var observer = new MyObserver("Marcin");

            var sub = source.Subscribe(observer);

            source.OnNext("Hello");

            var observer2 = new MyObserver("Bartek");

            source.Subscribe(observer2);

            source.OnError(new Exception("failure"));

            sub.Dispose();

            source.OnNext("Intel");



            source.OnCompleted();
        }
Ejemplo n.º 2
0
        public static void ObserverAndObservableTest()
        {
            var source = new SimpleColdSource();

            var observer1 = new MyObserver("Marcin");
            var observer2 = new MyObserver("Bartek");

            using (var subscibtion = source.Subscribe(observer1))
            {
            }

            source.Subscribe(observer2);

            //subscibtion.Dispose();
        }