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 Spotlight.pause() and 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 Spotlight.pause() and 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();
import Pause from '@enact/spotlight/Pause';

Members

PauseClass

Acts as a semaphore for Spotlight pause state ensuring that only the last Pause instance can resume Spotlight.

Note spotlight/Spotlight.resume will always resume spotlight regardless of what last paused spotlight and can be used as an escape hatch to force resumption.

import Pause from '@enact/spotlight/Pause';
Constructor
Pause(name)

Accepts a name for the instance

The name is not used but may be useful for debugging which instance has currently paused Spotlight.

1 Param
name String

The name of the pause instance

Statics
isPaused()Boolean

Returns true when Spotlight is paused by this instance

Returns
Boolean
pause()

Pauses spotlight if not currently paused

resume()Boolean

Resumes spotlight if this instance was the last to pause spotlight

Returns
Boolean

true if spotlight was resumed

ArrayBooleanFunctionModuleNumberObjectString