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

Make take/drop not share state across subscriptions #155

Merged
merged 1 commit into from
Jul 11, 2024

Conversation

Jamesernator
Copy link
Contributor

@Jamesernator Jamesernator commented Jul 11, 2024

As spec-ed the behaviour of take/drop means this prints the values only once:

const obs = Observable.from([1,2,3,4,5,6]);
const firstThree = obs.take(3);

firstThree.forEach((v) => {
    console.log(v);
});

// This doesn't print anything
firstThree.forEach((v) => {
    console.log(v);
});

The intended behaviour I would expect is that each subscription has it's own counter.

The fix provided here just makes a new variable local to each subscription rather than re-using the argument to take/drop.


Preview | Diff

@w3cbot
Copy link

w3cbot commented Jul 11, 2024

domfarolino marked as non substantive for IPR from ash-nazg.

Copy link
Collaborator

@domfarolino domfarolino left a comment

Choose a reason for hiding this comment

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

Great catch! Looks like the tests already assert this as well, so this is a simple bug fix that we just land right now.

@domfarolino domfarolino merged commit b8ee44b into WICG:master Jul 11, 2024
2 checks passed
github-actions bot added a commit that referenced this pull request Jul 11, 2024
SHA: b8ee44b
Reason: push, by domfarolino

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants