-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #127 from tusharmath/perf-updates
perf(scheduler): optimize constructor of tasks
- Loading branch information
Showing
17 changed files
with
167 additions
and
132 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import {Scheduler} from '../types/Scheduler' | ||
import {ITask} from '../types/ITask' | ||
import {Subscription} from '../types/core/Subscription' | ||
/** | ||
* Created by tushar on 05/02/17. | ||
*/ | ||
|
||
interface Global { | ||
requestIdleCallback?: Function | ||
process?: {nextTick: Function} | ||
setTimeout: Function | ||
} | ||
|
||
function getGlobal (): Global { | ||
return typeof window === 'object' ? window : global | ||
} | ||
|
||
export function asap (sh: Scheduler, task: ITask): Subscription { | ||
const global = getGlobal() | ||
if (global.requestIdleCallback) return sh.requestIdleCallback(task) | ||
if (global.process) return sh.nextTick(task) | ||
return sh.setTimeout(task, 1) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.