本文整理汇总了C#中Subject.ZipLatest方法的典型用法代码示例。如果您正苦于以下问题:C# Subject.ZipLatest方法的具体用法?C# Subject.ZipLatest怎么用?C# Subject.ZipLatest使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Subject
的用法示例。
在下文中一共展示了Subject.ZipLatest方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ZipLatestNth
public void ZipLatestNth()
{
var a = new Subject<int>();
var b = new Subject<int>();
var c = new Subject<int>();
var d = new Subject<int>();
var record = a.ZipLatest(b, c, d, (x, y, z, w) => new { x, y, z, w }).Record();
a.OnNext(1);
b.OnNext(2);
c.OnNext(3);
record.Values.Count.Is(0);
d.OnNext(4);
record.Values[0].Is(new { x = 1, y = 2, z = 3, w = 4 });
a.OnNext(10);
record.Values.Count.Is(1);
b.OnNext(20);
c.OnNext(30);
d.OnNext(40);
record.Values[1].Is(new { x = 10, y = 20, z = 30, w = 40 });
// complete
a.OnCompleted();
record.Notifications.Count.Is(2);
b.OnNext(200);
record.Notifications.Count.Is(3);
record.Notifications.Last().Kind.Is(NotificationKind.OnCompleted);
}
示例2: ZipLatest2
public void ZipLatest2()
{
var a = new Subject<int>();
var b = new Subject<int>();
a.OnNext(10);
b.OnNext(20);
var l = Enumerable.Empty<Unit>().Select(_ => Notification.CreateOnNext(new { x = 0, y = 0 })).ToList();
a.ZipLatest(b, (x, y) => new { x, y }).Materialize().Subscribe(x => l.Add(x));
a.OnNext(1000);
b.OnNext(2000);
l[0].Value.Is(new { x = 1000, y = 2000 });
b.OnNext(3000);
l.Count.Is(1);
a.OnNext(5000);
l[1].Value.Is(new { x = 5000, y = 3000 });
a.OnNext(9999); // one more
a.OnCompleted();
l.Count.Is(2);
a.OnNext(1001);
l.Count.Is(2);
b.OnNext(5);
l.Count.Is(4);
l[2].Value.Is(new { x = 9999, y = 5 });
l[3].Kind.Is(NotificationKind.OnCompleted);
}
示例3: ZipLatest2Ex
public void ZipLatest2Ex()
{
var a = new Subject<int>();
var b = new Subject<int>();
a.OnNext(10);
b.OnNext(20);
var l = Enumerable.Empty<Unit>().Select(_ => Notification.CreateOnNext(new { x = 0, y = 0 })).ToList();
a.ZipLatest(b, (x, y) => new { x, y }).Materialize().Subscribe(x => l.Add(x));
b.OnNext(2000);
a.OnCompleted();
l.Count.Is(0);
b.OnNext(30);
l.Count.Is(1);
l[0].Kind.Is(NotificationKind.OnCompleted);
}
示例4: ZipLatest
public void ZipLatest()
{
SetScehdulerForImport();
var a = new Subject<int>();
var b = new Subject<int>();
a.OnNext(10);
b.OnNext(20);
var l = Enumerable.Empty<Unit>().Select(_ => Notification.CreateOnNext(new { x = 0, y = 0 })).ToList();
a.ZipLatest(b, (x, y) => new { x, y }).Materialize().Subscribe(x => l.Add(x));
a.OnNext(1000);
b.OnNext(2000);
l[0].Value.Is(new { x = 1000, y = 2000 });
b.OnNext(3000);
l.Count.Is(1);
a.OnNext(5000);
l[1].Value.Is(new { x = 5000, y = 3000 });
a.OnCompleted();
l.Count.Is(2);
a.OnNext(1001);
l.Count.Is(2);
b.OnNext(5);
l.Count.Is(3);
l[2].Kind.Is(NotificationKind.OnCompleted);
UniRx.Scheduler.SetDefaultForUnity();
}