-
Notifications
You must be signed in to change notification settings - Fork 7.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Operator: Latest #59
Comments
Is |
I believe latest can return a value from the past but falls back the next value if one hasn't been received yet. |
@abersnaze , Do you mean if the next value hasn't arrived, the latest will return the old cached value? But there are the following codes in the TryMoveNext method of Latest. public override bool TryMoveNext(out TSource current)
{
var kind = default(NotificationKind);
var value = default(TSource);
var error = default(Exception);
#if !NO_CDS
_semaphore.Wait();
#else
_semaphore.WaitOne();
#endif So when I tried the following codes in Rx.Next: IObservable<int> ob =
Observable.Create<int>(o =>
{
Console.WriteLine("Subscribed: Before onNext");
o.OnNext(1);
Thread.Sleep(2000);
o.OnNext(2);
Console.WriteLine("Subscribed: After OnNext");
o.OnCompleted();
return Disposable.Empty;
}
);
var iter = ob.SubscribeOn(Scheduler.NewThread).Latest().GetEnumerator();
Console.WriteLine("Before MoveNext");
while (iter.MoveNext())
{
Console.WriteLine("Find a value");
Console.WriteLine("Got " + iter.Current);
}
Console.WriteLine("After MoveNext"); The output is: Before MoveNext Subscribed: Before onNext Find a value Got 1 Subscribed: After OnNext Find a value Got 2 After MoveNext |
I did some tests on Rx.Net about I draw two Marble diagrams to summary the differences between
For
For Please let me know if you find any mistake. |
So Looking at |
However, as the |
@zsxwing Are you going to implement this? In addition, I've looked at the OperationMostRecent, and if I understand it correctly, it shares a single subscription to the source observable, i.e, if I try to iterate the same source twice, it won't work the second time: BlockingObservable<Long> source = Observable.interval(100, TimeUnit.MILLISECONDS)
.take(10).toBlockingObservable();
Iterable<Long> it = source.mostRecent(-1L);
for (Long l : it) {
System.out.println(l);
Thread.sleep(50);
}
System.out.println("----------------------------------------");
for (Long l : it) {
System.out.println(l);
Thread.sleep(50);
} Same goes for I can fix both mostRecent and next and take latest. |
You're right. The |
I'm on it. Thanks. |
Implemented. |
Project has been renamed to resilience4j and has been modularized.
http://msdn.microsoft.com/en-us/library/hh212115(v=vs.103).aspx
The text was updated successfully, but these errors were encountered: