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

refactor(switchLatest): make switchLatest a standalone impl, add virtual time tests #317

Merged
merged 2 commits into from
Sep 17, 2015
Merged

refactor(switchLatest): make switchLatest a standalone impl, add virtual time tests #317

merged 2 commits into from
Sep 17, 2015

Conversation

benlesh
Copy link
Member

@benlesh benlesh commented Sep 16, 2015

  • completely refactors switchLatest to be a standalone implementation
  • adds a lot of tests around switch latest

@benlesh benlesh changed the title Switch latest tests refactor(switchLatest): make switchLatest a standalone impl, add virtual time tests Sep 16, 2015
@@ -3,15 +3,166 @@ var Rx = require('../../dist/cjs/Rx');
var Observable = Rx.Observable;
var immediateScheduler = Rx.Scheduler.immediate;

describe('Observable.prototype.switchLatest()', function () {
fdescribe('Observable.prototype.switchLatest()', function () {
Copy link
Member

Choose a reason for hiding this comment

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

fdescribe?

Copy link
Member Author

Choose a reason for hiding this comment

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

Oops. Good catch.

That's to limit jasmine tests to just that grouping during development. I meant to remove that.

- adds a lot of virtual tests around switchLatest
- switchLatest no longer depends on flatMap

addresses #302
…unsub

- ensures that inner subscriptions are NOT provided a destination, which changes the executiong path of unsubscribe()

fixes #302
@benlesh benlesh merged commit 38a45f8 into ReactiveX:master Sep 17, 2015
@@ -58,13 +66,18 @@ class SwitchSubscriber<T> extends Subscriber<T> {
}

class InnerSwitchSubscriber<T> extends Subscriber<T> {
constructor(destination: Observer<any>, private parent: SwitchSubscriber<T>) {
super(destination);
Copy link
Member

Choose a reason for hiding this comment

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

@Blesh couldn't we still set destination on the InnerSwitchSubscriber, but invoke super with no argument? I believe the only logic we want to short-circuit here is the shared _subscription assignment. Then we don't have to override _next or _error.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, that would probably work. If you want to make that change, feel free to PR.

Copy link
Member

Choose a reason for hiding this comment

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

I'm going to devote some thought to the whole shared-subscription approach and see if I can poke any more holes in it. The solution may be as simple as explicitly passing the shared subscription to Subscriber's constructor, instead of reading it off the destination. Will let you know.

@benlesh benlesh deleted the switchLatest-tests branch April 27, 2016 17:20
@lock
Copy link

lock bot commented Jun 7, 2018

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Jun 7, 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.

3 participants