Skip to content

Commit

Permalink
Use named type instead of ReturnType<typeof...>
Browse files Browse the repository at this point in the history
  • Loading branch information
afshin committed Sep 11, 2022
1 parent 7dcd334 commit a02d471
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
2 changes: 1 addition & 1 deletion packages/coreutils/tests/src/schedule.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ describe('@lumino/coreutils', () => {
it('should allow a callback to be unscheduled', async () => {
let called = false;
unschedule(schedule(() => (called = true)));
await sleep(20);
await sleep(100);
expect(called).to.equal(false);
});
});
Expand Down
4 changes: 2 additions & 2 deletions packages/messaging/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { ArrayExt, every, retro, some } from '@lumino/algorithm';

import { LinkedList } from '@lumino/collections';

import { schedule, unschedule } from '@lumino/coreutils';
import { schedule, ScheduleHandle, unschedule } from '@lumino/coreutils';

/**
* A message which can be delivered to a message handler.
Expand Down Expand Up @@ -472,7 +472,7 @@ export namespace MessageLoop {
/**
* The id of the pending loop task animation frame.
*/
let loopTaskID: ReturnType<typeof schedule> = 0;
let loopTaskID: ScheduleHandle = 0;

/**
* A guard flag to prevent flush recursion.
Expand Down
10 changes: 8 additions & 2 deletions packages/polling/src/poll.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
JSONExt,
PromiseDelegate,
schedule,
ScheduleHandle,
unschedule
} from '@lumino/coreutils';

Expand Down Expand Up @@ -38,7 +39,7 @@ export class Poll<T = any, U = any, V extends string = 'standby'>
constructor(options: Poll.IOptions<T, U, V>) {
this.standby = options.standby || Private.DEFAULT_STANDBY;
this._factory = options.factory;
this._linger = options.linger ?? 1;
this._linger = options.linger ?? Private.DEFAULT_LINGER;
this._state = { ...Private.DEFAULT_STATE, timestamp: new Date().getTime() };

// Normalize poll frequency `max` to be the greater of
Expand Down Expand Up @@ -339,7 +340,7 @@ export class Poll<T = any, U = any, V extends string = 'standby'>
private _disposed = new Signal<this, void>(this);
private _factory: Poll.Factory<T, U, V>;
private _frequency: IPoll.Frequency;
private _handle: ReturnType<typeof schedule> = -1;
private _handle: ScheduleHandle = -1;
private _linger: number;
private _lingered = 0;
private _state: IPoll.State<T, U, V>;
Expand Down Expand Up @@ -455,6 +456,11 @@ namespace Private {
max: 30 * 1000
};

/**
* The default number of times to `linger` when a poll is hidden.
*/
export const DEFAULT_LINGER = 1;

/**
* The default poll name.
*/
Expand Down

0 comments on commit a02d471

Please sign in to comment.