Skip to content

Finally Happens after onCompleted #277

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

Closed
benjchristensen opened this issue May 22, 2013 · 2 comments
Closed

Finally Happens after onCompleted #277

benjchristensen opened this issue May 22, 2013 · 2 comments
Labels

Comments

@benjchristensen
Copy link
Member

Looks like finallyDo is behaving wrong:

package rx.lang.groovy.examples
import rx.Observable

class Testing {

    static class myActionClass implements rx.util.functions.Action0 {
        void call() { println('Finally'); }
     }

    static main(args) {



        def myAction = new myActionClass();
        def numbers = Observable.toObservable([1, 2, 3, 4, 5]);

        numbers.finallyDo(myAction).subscribe(
          [ onNext: { println(it); },
            onCompleted:{ println("Sequence complete"); },
            onError:{ println("Error encountered"); } ]
        );

    }

}
Output:

1
2
3
4
5
Sequence complete
Finally

I believe "Finally" should happen before "Sequence Completed"

@prabirshrestha
Copy link
Contributor

This issues was raised when finally PR was being sent. #196 (comment)

Here is the C# equivalent code I just checked with.

using System;
using System.Reactive.Linq;

var members = new[] { 1, 2, 3, 4, 5 }.ToObservable();

members
    .Finally(() => Console.WriteLine("Finally"))
    .Subscribe(Console.WriteLine /* next */, Console.WriteLine /* exception */, () => Console.WriteLine("Sequence Completed"));

Output:

1
2
3
4
5
Sequence Completed
Finally

Current behavior is correct.

@benjchristensen
Copy link
Member Author

Great. Thank you for confirming with C# code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants