当前位置: 首页>>代码示例>>C#>>正文


C# Subject.TakeUntil方法代码示例

本文整理汇总了C#中Subject.TakeUntil方法的典型用法代码示例。如果您正苦于以下问题:C# Subject.TakeUntil方法的具体用法?C# Subject.TakeUntil怎么用?C# Subject.TakeUntil使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Subject的用法示例。


在下文中一共展示了Subject.TakeUntil方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: TakeUntil

        public void TakeUntil()
        {
            {
                var a = new Subject<int>();
                var b = new Subject<int>();

                var l = new List<Notification<int>>();

                a.TakeUntil(b).Materialize().Subscribe(l.Add);

                a.OnNext(1);
                a.OnNext(10);
                b.OnNext(1000);
                l.Count.Is(3);
                l[0].Value.Is(1);
                l[1].Value.Is(10);
                l[2].Kind.Is(NotificationKind.OnCompleted);
            }
            {
                var a = new Subject<int>();
                var b = new Subject<int>();

                var l = new List<Notification<int>>();

                a.TakeUntil(b).Materialize().Subscribe(l.Add);

                a.OnNext(1);
                a.OnNext(10);
                b.OnCompleted();
                l.Count.Is(2);

                b.OnNext(1000);
                l.Count.Is(2);

                a.OnNext(100);
                l.Count.Is(3);
                l[0].Value.Is(1);
                l[1].Value.Is(10);
                l[2].Value.Is(100);
            }
        }
开发者ID:ragcat,项目名称:UniRx,代码行数:41,代码来源:UnitTests.cs

示例2: Run


//.........这里部分代码省略.........
            subject.OnNext(2);
            subject.OnNext(1);
            subject.OnCompleted();
              }

              {
            Console.WriteLine("= TakeWhile =======");
            var subject = new Subject<int>();
            subject
              .TakeWhile(i => i < 4)
              .Subscribe(
            Console.WriteLine,
            () => Console.WriteLine("OnCompleted()"));

            subject.OnNext(1);
            subject.OnNext(2);
            subject.OnNext(3);
            subject.OnNext(4);
            subject.OnNext(3);
            subject.OnNext(2);
            subject.OnNext(1);
            subject.OnCompleted();
              }

              {
            Console.WriteLine("= SkipLast =======");
            var subject = new Subject<int>();
            subject
              .SkipLast(2)
              .Subscribe(Console.WriteLine, () => Console.WriteLine("Completed"));

            Console.WriteLine("Pushing 1");
            subject.OnNext(1);
            Console.WriteLine("Pushing 2");
            subject.OnNext(2);
            Console.WriteLine("Pushing 3");
            subject.OnNext(3);
            Console.WriteLine("Pushing 4");
            subject.OnNext(4);
            subject.OnCompleted();
              }

              {
            Console.WriteLine("= TakeLast =======");
            var subject = new Subject<int>();
            subject
              .TakeLast(2)
              .Subscribe(Console.WriteLine, () => Console.WriteLine("Completed"));

            Console.WriteLine("Pushing 1");
            subject.OnNext(1);
            Console.WriteLine("Pushing 2");
            subject.OnNext(2);
            Console.WriteLine("Pushing 3");
            subject.OnNext(3);
            Console.WriteLine("Pushing 4");
            subject.OnNext(4);
            subject.OnCompleted();
              }

              {
            Console.WriteLine("= SkipUntil =======");
            var subject = new Subject<int>();
            var otherSubject = new Subject<Unit>();
            subject
              .SkipUntil(otherSubject)
              .Subscribe(Console.WriteLine, () => Console.WriteLine("Completed"));

            subject.OnNext(1);
            subject.OnNext(2);
            subject.OnNext(3);
            otherSubject.OnNext(Unit.Default);
            subject.OnNext(4);
            subject.OnNext(5);
            subject.OnNext(6);
            subject.OnNext(7);
            subject.OnNext(8);
            subject.OnCompleted();
              }

              {
            Console.WriteLine("= TakeUntil =======");
            var subject = new Subject<int>();
            var otherSubject = new Subject<Unit>();
            subject
              .TakeUntil(otherSubject)
              .Subscribe(Console.WriteLine, () => Console.WriteLine("Completed"));

            subject.OnNext(1);
            subject.OnNext(2);
            subject.OnNext(3);
            otherSubject.OnNext(Unit.Default);
            subject.OnNext(4);
            subject.OnNext(5);
            subject.OnNext(6);
            subject.OnNext(7);
            subject.OnNext(8);
            subject.OnCompleted();
              }
        }
开发者ID:pudae,项目名称:lplpl,代码行数:101,代码来源:TestSkipTake.cs

示例3: TakeUntilFull

 public void TakeUntilFull()
 {
     var received = "";
     var subject = new Subject<int>();
     subject.TakeUntil(subject.Where(x => x > ____)).Subscribe(x => received += x);
     subject.OnNext(Range.Create(1, 9).ToArray());
     Assert.AreEqual("12345", received);
 }
开发者ID:nickh,项目名称:rxkoans,代码行数:8,代码来源:Lesson1ObservableStreams.cs

示例4: TakeUntil

 public void TakeUntil()
 {
     SetScehdulerForImport();
     {
         var a = new Subject<int>();
         var b = new Subject<int>();
         var l = new List<Notification<int>>();
         a.TakeUntil(b).Materialize().Subscribe(l.Add);
         a.OnNext(1);
         a.OnNext(10);
         b.OnNext(1000);
         l.Count.Is(3);
         l[0].Value.Is(1);
         l[1].Value.Is(10);
         l[2].Kind.Is(NotificationKind.OnCompleted);
     }
     {
         var a = new Subject<int>();
         var b = new Subject<int>();
         var l = new List<Notification<int>>();
         a.TakeUntil(b).Materialize().Subscribe(l.Add);
         a.OnNext(1);
         a.OnNext(10);
         b.OnCompleted();
         l.Count.Is(2);
         b.OnNext(1000);
         l.Count.Is(2);
         a.OnNext(100);
         l.Count.Is(3);
         l[0].Value.Is(1);
         l[1].Value.Is(10);
         l[2].Value.Is(100);
     }
     UniRx.Scheduler.SetDefaultForUnity();
 }
开发者ID:neuecc,项目名称:UniRx,代码行数:35,代码来源:TestImporter.cs

示例5: TakeUntil

 public void TakeUntil()
 {
     var subject = new Subject<int>();
     var otherSubject = new Subject<Unit>();
     subject
     .TakeUntil(otherSubject)
     .Subscribe(Console.WriteLine, () => Console.WriteLine("Completed"));
     subject.OnNext(1);
     subject.OnNext(2);
     subject.OnNext(3);
     otherSubject.OnNext(Unit.Default);
     subject.OnNext(4);
     subject.OnNext(5);
     subject.OnNext(6);
     subject.OnNext(7);
     subject.OnNext(8);
     subject.OnCompleted();
 }
开发者ID:sam-io,项目名称:dotnet-playground,代码行数:18,代码来源:Rx_seq_3_Skip_and_Take.cs


注:本文中的Subject.TakeUntil方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。