Skip to content
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

fix(skipUntil): fix skipUntil when innerSubscription is null #3686

Merged
merged 3 commits into from
May 21, 2018

Conversation

claylaut
Copy link
Contributor

@claylaut claylaut commented May 11, 2018

Description: Fix a minor issue with skipUntil

Related issue:
#3685

@cartant
Copy link
Collaborator

cartant commented May 11, 2018

Your fix looks appropriate, to me, but, ideally, the PR should also include a test that's based on code that reproduces the error.

The problem is effected because the implementation doesn't account for the synchronous completion of the notifier. You don't need to use a BehaviorSubject to effect the error; a simple, synchronous observable will do:

import { of } from "rxjs";
import { skipUntil } from "rxjs/operators";

of(1).pipe(
  skipUntil(of(2))
).subscribe(x => console.log(x));

@claylaut
Copy link
Contributor Author

claylaut commented May 11, 2018

@cartant I've just simplified my usage example and opened an issue.
I've tested the fix by modifying the node modules and it worked fine.

I m unsure how to do the test if you can guide me I will appreciate it.

@cartant
Copy link
Collaborator

cartant commented May 11, 2018

Sure.

Interestingly, I cannot get a marble test to effect the error, so I'd just add a test based on the repro. You could add one like this:

  it('should emit elements after a synchronous notifer emits', () => {
    const values: string[] = [];

    of('a', 'b').pipe(skipUntil(of('x'))).subscribe(
      value => values.push(value),
      err => { throw err; },
      () => expect(values).to.deep.equal(['a', 'b'])
    );
  });

I'd add it after the test named 'should emit elements after notifer emits' - near the top of the https://github.com/ReactiveX/rxjs/blob/master/spec/operators/skipUntil-spec.ts file.

Once you've added the test to the file, run npm run test to run the test suite. With your fix, it should pass. Then commit the test to your branch and forcibly push it to your repo with git push -f. That will see the PR updated.

@claylaut
Copy link
Contributor Author

@cartant thanks a lot for your help.
I've updated the tests and they passed successfully.
PR Updated.

@@ -57,7 +57,9 @@ class SkipUntilSubscriber<T, R> extends OuterSubscriber<T, R> {
outerIndex: number, innerIndex: number,
innerSub: InnerSubscriber<T, R>): void {
this.hasValue = true;
this.innerSubscription.unsubscribe();
if(this.innerSubscription) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is just nitpicking but in all code around here there's always space between if and the starting parenthesis if (this.innerSubscription).

Copy link
Contributor Author

@claylaut claylaut May 15, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@martinsik fixed

@rxjs-bot
Copy link

Warnings
⚠️

commit message does not follows conventional change log (1)

(1) : RxJS uses conventional change log to generate changelog automatically. It seems some of commit messages are not following those, please check contributing guideline and update commit messages.

Generated by 🚫 dangerJS

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.2%) to 96.657% when pulling a36f718 on claylaut:feature/fix-skipUntil into dc66731 on ReactiveX:master.

@claylaut
Copy link
Contributor Author

@cartant / @martinsik any progress on this? its quite important this for me because without it i cannot migrate to rxjs 6

@cartant
Copy link
Collaborator

cartant commented May 18, 2018

@claylaut The repository's maintainers will eventually get around to reviewing and, likely, merging your PR. You will just need to be a little patient, as they're busy people with other priorities. In the interim, you could use a scheduler for a temporary workaround:

import { asapScheduler, of } from "rxjs";
import { skipUntil } from "rxjs/operators";

of(1).pipe(
  skipUntil(of(2, asapScheduler)) // or skipUntil(of(2).pipe(subscribeOn(asapScheduler)))
).subscribe(x => console.log(x));

@benlesh
Copy link
Member

benlesh commented May 21, 2018

Thanks, @claylaut!

@benlesh benlesh merged commit 4226432 into ReactiveX:master May 21, 2018
@claylaut
Copy link
Contributor Author

@benlesh thanks for merge.

@cartant thanks for the workaround 👍

@lock lock bot locked as resolved and limited conversation to collaborators Jun 20, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants