Skip to content

Commit

Permalink
fix(scheduler): resolve regression on angular router with zones (#3158)
Browse files Browse the repository at this point in the history
* fix(scheduler): resolve regression on angular router with zones

This reverts commit 7d722d4.

* chore(package): pin down symbol-observable
  • Loading branch information
kwonoj committed Dec 4, 2017
1 parent 6ebc565 commit 520b06a
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 58 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,6 @@
},
"typings": "./dist/package/Rx.d.ts",
"dependencies": {
"symbol-observable": "^1.0.1"
"symbol-observable": "1.0.1"

This comment has been minimized.

Copy link
@Brooooooklyn

Brooooooklyn Dec 7, 2017

Contributor

why?

}
}
53 changes: 0 additions & 53 deletions spec/schedulers/AsapScheduler-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,59 +40,6 @@ describe('Scheduler.asap', () => {
sandbox.restore();
});

it('should reuse the interval for recursively scheduled actions with the same delay', () => {
const sandbox = sinon.sandbox.create();
const fakeTimer = sandbox.useFakeTimers();
// callThrough is missing from the declarations installed by the typings tool in stable
const stubSetInterval = (<any> sinon.stub(global, 'setInterval')).callThrough();
function dispatch(state: any): void {
state.index += 1;
if (state.index < 3) {
(<any> this).schedule(state, state.period);
}
}
const period = 50;
const state = { index: 0, period };
asap.schedule(dispatch, period, state);
expect(state).to.have.property('index', 0);
expect(stubSetInterval).to.have.property('callCount', 1);
fakeTimer.tick(period);
expect(state).to.have.property('index', 1);
expect(stubSetInterval).to.have.property('callCount', 1);
fakeTimer.tick(period);
expect(state).to.have.property('index', 2);
expect(stubSetInterval).to.have.property('callCount', 1);
stubSetInterval.restore();
sandbox.restore();
});

it('should not reuse the interval for recursively scheduled actions with a different delay', () => {
const sandbox = sinon.sandbox.create();
const fakeTimer = sandbox.useFakeTimers();
// callThrough is missing from the declarations installed by the typings tool in stable
const stubSetInterval = (<any> sinon.stub(global, 'setInterval')).callThrough();
function dispatch(state: any): void {
state.index += 1;
state.period -= 1;
if (state.index < 3) {
(<any> this).schedule(state, state.period);
}
}
const period = 50;
const state = { index: 0, period };
asap.schedule(dispatch, period, state);
expect(state).to.have.property('index', 0);
expect(stubSetInterval).to.have.property('callCount', 1);
fakeTimer.tick(period);
expect(state).to.have.property('index', 1);
expect(stubSetInterval).to.have.property('callCount', 2);
fakeTimer.tick(period);
expect(state).to.have.property('index', 2);
expect(stubSetInterval).to.have.property('callCount', 3);
stubSetInterval.restore();
sandbox.restore();
});

it('should schedule an action to happen later', (done: MochaDone) => {
let actionHappened = false;
asap.schedule(() => {
Expand Down
8 changes: 4 additions & 4 deletions src/scheduler/AsyncAction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ export class AsyncAction<T> extends Action<T> {
// Always replace the current state with the new state.
this.state = state;

// Set the pending flag indicating that this action has been scheduled, or
// has recursively rescheduled itself.
this.pending = true;

const id = this.id;
const scheduler = this.scheduler;

Expand Down Expand Up @@ -57,10 +61,6 @@ export class AsyncAction<T> extends Action<T> {
this.id = this.recycleAsyncId(scheduler, id, delay);
}

// Set the pending flag indicating that this action has been scheduled, or
// has recursively rescheduled itself.
this.pending = true;

this.delay = delay;
// If this action has already an async Id, don't request a new one.
this.id = this.id || this.requestAsyncId(scheduler, this.id, delay);
Expand Down

0 comments on commit 520b06a

Please sign in to comment.