What does the Wait statement in Rx.NET do?

In v2.2.5 of the Rx.NET library, there is an operator with a name Waitthat is defined as such:

public virtual TSource Wait<TSource>(IObservable<TSource> source)

Neither the link to the class library on MSDN nor this page mention this statement.

From looking at its implementation, which is too cumbersome to follow, I assume that she expects the observable to produce all its elements and returns the last element if the observable has any elements, and if not, it returns default(TSource). But I'm not sure.

If this is correct, then how does it differ from LastOrDefaultAsync?

What is he really doing?

0
source share
3 answers

Wait, , .

Wait LastOrDefaultAsync:

  • . , , Wait , LastOrDefaultAsync .

Wait LastOrDefaultAsync:

  • , Wait ; LastOrDefault default(TSource).

  • , Wait , observer.OnError, ; LastOrDefaultAsync , observer.OnError . .

XML, ( NuGet MSI) Rx, , :

Expects that the observed sequence will be completed and will return the last element of the sequence. If the sequence ends with an OnError notification, the exception is a throw.

Exceptions

Throws ArgumentNullExceptionif sourcenull.

Throws InvalidOperationExceptionif the sequence is sourceempty.

0
source

Source: https://habr.com/ru/post/1684956/


All Articles