-
Notifications
You must be signed in to change notification settings - Fork 55
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 #274 from bvaughn/commit-priority-level
Show commit priority levels in Profiler UI (if available)
- Loading branch information
Showing
14 changed files
with
209 additions
and
51 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 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,46 @@ | ||
// @flow | ||
|
||
import React, { Fragment, useCallback, useState } from 'react'; | ||
import { | ||
unstable_IdlePriority as IdlePriority, | ||
unstable_LowPriority as LowPriority, | ||
unstable_runWithPriority as runWithPriority, | ||
} from 'scheduler'; | ||
|
||
export default function PriorityLevels() { | ||
const [defaultPriority, setDefaultPriority] = useState<boolean>(false); | ||
const [idlePriority, setIdlePriority] = useState<boolean>(false); | ||
const [normalPriority, setLowPriority] = useState<boolean>(false); | ||
|
||
const resetSequence = useCallback(() => { | ||
setDefaultPriority(false); | ||
setLowPriority(false); | ||
setIdlePriority(false); | ||
}, []); | ||
|
||
const startSequence = useCallback(() => { | ||
setDefaultPriority(true); | ||
runWithPriority(LowPriority, () => setLowPriority(true)); | ||
runWithPriority(IdlePriority, () => setIdlePriority(true)); | ||
}, []); | ||
|
||
const labels = []; | ||
if (defaultPriority) { | ||
labels.push('(default priority)'); | ||
} | ||
if (normalPriority) { | ||
labels.push('Low Priority'); | ||
} | ||
if (idlePriority) { | ||
labels.push('Idle Priority'); | ||
} | ||
|
||
return ( | ||
<Fragment> | ||
<h1>Priority Levels</h1> | ||
<button onClick={resetSequence}>Reset</button> | ||
<button onClick={startSequence}>Start sequence</button> | ||
<span>{labels.join(', ')}</span> | ||
</Fragment> | ||
); | ||
} |
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.