spotlight/Pause
Provides a class which allows consumers to safely pause and resume spotlight without resuming another consumer's pause.
When multiple components attempt to pause and resume spotlight at overlapping times using spotlightspotlight.Spotlight.pause and spotlightspotlight.Spotlight.resume, one component might resume spotlight when another expected it to still be paused.
Pause helps to address this by setting a "soft lock" on the pause which informs other instances
that the spotlight pause state is being controlled. When pause is locked, it can only be resumed
by the instance that locked it. Subsequent calls to pause and resume on another instance of
Pause have no effect.
Note: The top-level spotlightspotlight.Spotlight.pause and spotlightspotlight.Spotlight.resume do not respect the pause locks and act as a user-space escape hatch.
import Pause from '@enact/spotlight/Pause';
const paused1 = new Pause('paused 1');
const paused2 = new Pause('paused 2');
// pauses spotlight
paused1.pause();
// has no effect because pause1 is in control
paused2.pause();
// has no effect because pause1 is in control
paused2.resume();
// resumes spotlight
paused1.resume();
Interactive Demo
Section titled “Interactive Demo ”Members
Section titled “Members ”Pause Class
Section titled “Pause   Class ”Acts as a semaphore for Spotlight pause state ensuring that only the last Pause instance can resume Spotlight.
Note spotlight/Spotlightspotlight/Spotlight.resume will always resume spotlight regardless of what last paused spotlight and can be used as an escape hatch to force resumption.
Constructor
Pause(name)
Section titled “Pause(name)”1 Param
- name String
The name of the pause instance
Returns
Accepts a name for the instance
The name is not used but may be useful for debugging which instance has currently paused
Spotlight.
Methods
isPaused()
Section titled “isPaused()”Returns true when Spotlight is paused by this instance
0 Params
Returns
- Boolean
pause()
Section titled “pause()”Pauses spotlight if not currently paused
0 Params
Returns
- undefined
resume()
Section titled “resume()”Resumes spotlight if this instance was the last to pause spotlight
0 Params
Returns
- Boolean
trueif spotlight was resumed