本文整理汇总了C#中Subject.DistinctUntilChanged方法的典型用法代码示例。如果您正苦于以下问题:C# Subject.DistinctUntilChanged方法的具体用法?C# Subject.DistinctUntilChanged怎么用?C# Subject.DistinctUntilChanged使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Subject
的用法示例。
在下文中一共展示了Subject.DistinctUntilChanged方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DistinctUntilChanged
public void DistinctUntilChanged()
{
{
var subject = new Subject<int>();
int[] array = null;
var disp = subject.DistinctUntilChanged().ToArray().Subscribe(xs => array = xs);
Array.ForEach(new[] { 1, 10, 10, 1, 100, 100, 100, 5 }, subject.OnNext);
subject.OnCompleted();
array.Is(1, 10, 1, 100, 5);
}
{
var subject = new Subject<int>();
int[] array = null;
var disp = subject.DistinctUntilChanged(x => x, EqualityComparer<int>.Default).ToArray().Subscribe(xs => array = xs);
Array.ForEach(new[] { 1, 10, 10, 1, 100, 100, 100, 5 }, subject.OnNext);
subject.OnCompleted();
array.Is(1, 10, 1, 100, 5);
}
}
示例2: InputComponent
public InputComponent(PuzzlePathGame game)
: base(game)
{
Source = new Subject<VirtualControllerState>();
// Skip duplicate state-steps.
InputStates = Source.DistinctUntilChanged().Publish().RefCount();
}
示例3: Run
public static void Run()
{
{
var subject = new Subject<int>();
var distinct = subject.Distinct();
subject.Subscribe(
i => Console.WriteLine("{0}", i),
() => Console.WriteLine("subject.OnCompleted()"));
distinct.Subscribe(
i => Console.WriteLine("distinct.OnNext{0}", i),
() => Console.WriteLine("distinct..OnCompleted()"));
subject.OnNext(1);
subject.OnNext(2);
subject.OnNext(3);
subject.OnNext(1);
subject.OnNext(1);
subject.OnNext(4);
subject.OnCompleted();
}
{
var subject = new Subject<int>();
var distinct = subject.DistinctUntilChanged();
subject.Subscribe(
i => Console.WriteLine("{0}", i),
() => Console.WriteLine("subject.OnCompleted()"));
distinct.Subscribe(
i => Console.WriteLine("distinct.OnNext{0}", i),
() => Console.WriteLine("distinct..OnCompleted()"));
subject.OnNext(1);
subject.OnNext(2);
subject.OnNext(3);
subject.OnNext(1);
subject.OnNext(1);
subject.OnNext(4);
subject.OnCompleted();
}
}
示例4: Run_Distinct_Until_Changed
/// <summary>
/// Published if previous value differs from current; otherwise skips
/// </summary>
public void Run_Distinct_Until_Changed()
{
ConsoleUtility.PrintSuccess(string.Format("Distinct until example"));
var subject = new Subject<int>();
var distinct = subject.DistinctUntilChanged();
subject.Subscribe(
i => Console.WriteLine("{0}", i),
() => Console.WriteLine("subject.OnCompleted()"));
distinct.Subscribe(
i => Console.WriteLine("distinct.OnNext({0})", i),
() => Console.WriteLine("distinct.OnCompleted()"));
subject.OnNext(1);
subject.OnNext(2);
subject.OnNext(3);
subject.OnNext(3);
subject.OnNext(3);
subject.OnNext(1);
subject.OnNext(1);
subject.OnNext(4);
subject.OnCompleted();
}
示例5: DistinctUntilChanged
public void DistinctUntilChanged()
{
{
var subject = new Subject<int>();
int[] array = null;
subject.DistinctUntilChanged().ToArray().Subscribe(xs => array = xs);
foreach (var item in new[] { 1, 10, 10, 1, 100, 100, 100, 5 }) { subject.OnNext(item); };
subject.OnCompleted();
array.IsCollection(1, 10, 1, 100, 5);
}
{
string[] array = null;
new[] { "hoge", "huga", null, null, "huga", "huga", "hoge" }
.ToObservable()
.DistinctUntilChanged()
.ToArray()
.Subscribe(xs => array = xs);
array.IsCollection("hoge", "huga", null, "huga", "hoge");
}
{
var subject = new Subject<int>();
int[] array = null;
subject.DistinctUntilChanged(x => x, EqualityComparer<int>.Default).ToArray().Subscribe(xs => array = xs);
foreach (var item in new[] { 1, 10, 10, 1, 100, 100, 100, 5 }) { subject.OnNext(item); };
subject.OnCompleted();
array.IsCollection(1, 10, 1, 100, 5);
}
}