本文整理汇总了C#中Subject.SkipUntil方法的典型用法代码示例。如果您正苦于以下问题:C# Subject.SkipUntil方法的具体用法?C# Subject.SkipUntil怎么用?C# Subject.SkipUntil使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Subject
的用法示例。
在下文中一共展示了Subject.SkipUntil方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SkipUntil
/// <summary>
/// Skips until the other seq publishes an item (Unit.Default)
/// </summary>
public void 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();
}
示例2: SkipUntil
public void SkipUntil()
{
{
var a = new Subject<int>();
var b = new Subject<int>();
var l = new List<Notification<int>>();
a.SkipUntil(b).Materialize().Subscribe(l.Add);
a.OnNext(1);
a.OnNext(10);
b.OnNext(1000);
l.Count.Is(0);
b.OnNext(99999);
b.HasObservers.IsFalse();
a.OnNext(1);
a.OnNext(10);
l[0].Value.Is(1);
l[1].Value.Is(10);
}
{
var a = new Subject<int>();
var b = new Subject<int>();
var l = new List<Notification<int>>();
a.SkipUntil(b).Materialize().Subscribe(l.Add);
a.OnNext(1);
a.OnNext(10);
b.OnCompleted();
l.Count.Is(0);
a.OnNext(100);
l.Count.Is(0);
}
}
示例3: Run
public static void Run()
{
{
Console.WriteLine("= Skip =======");
Observable.Range(0, 10)
.Skip(3)
.Subscribe(
Console.WriteLine,
() => Console.WriteLine("OnCompleted()"));
}
{
Console.WriteLine("= Take =======");
Observable.Range(0, 10)
.Take(3)
.Subscribe(
Console.WriteLine,
() => Console.WriteLine("OnCompleted()"));
}
{
Console.WriteLine("= SkipWhile =======");
var subject = new Subject<int>();
subject
.SkipWhile(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("= 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)
//.........这里部分代码省略.........
示例4: SkipUntil
public void SkipUntil()
{
SetScehdulerForImport();
{
var a = new Subject<int>();
var b = new Subject<int>();
var l = new List<Notification<int>>();
a.SkipUntil(b).Materialize().Subscribe(l.Add);
a.OnNext(1);
a.OnNext(10);
b.OnNext(1000);
l.Count.Is(0);
b.OnNext(99999);
b.HasObservers.IsFalse();
a.OnNext(1);
a.OnNext(10);
l[0].Value.Is(1);
l[1].Value.Is(10);
}
{
var a = new Subject<int>();
var b = new Subject<int>();
var l = new List<Notification<int>>();
a.SkipUntil(b).Materialize().Subscribe(l.Add);
a.OnNext(1);
a.OnNext(10);
b.OnCompleted();
l.Count.Is(0);
a.OnNext(100);
l.Count.Is(0);
}
UniRx.Scheduler.SetDefaultForUnity();
}