.watchers.pauseAll
Pauses all the currently registered watchers. NOTE: If a watcher is currently pending registration with Lampix, it will NOT be paused, as this methods concerns all of the watchers that have been registered successfully.

Returns

(Promise<void>): A promise that fulfills when all of the registered watchers have been paused. If a registered watcher is already paused, it will simply resolve automatically, bypassing Lampix.

Example

1
import lampix from '@lampix/core';
2
3
const state = {
4
registeredWatchers: []
5
};
6
7
const draw = (recognizedObjects) => {
8
// Drawing amazing effects
9
};
10
11
const watcher1 = {
12
name: 'DepthClassifier',
13
shape: lampix.helpers.rectangle(0, 0, window.innerWidth / 2, window.innerHeight),
14
onClassification: draw
15
};
16
17
const watcher2 = {
18
name: 'DepthClassifier',
19
shape: lampix.helpers.rectangle(window.innerWidth / 2, 0, window.innerWidth / 2, window.innerHeight),
20
onClassification: draw
21
};
22
23
lampix.watchers.add(watcher1, watcher2)
24
.then((registeredWatchers) => {
25
state.registeredWatchers = registeredWatchers;
26
27
// Remove them right away!
28
// The removal expression below is equivalent to
29
return lampix.watchers.pauseAll();
30
})
31
.then(() => {
32
// watcher1 and watcher2 are now paused
33
console.log(registeredWatchers[0].state.active); // false
34
console.log(registeredWatchers[1].state.active); // false
35
});
Copied!

Notes

You can pause a single registered watcher by using its .pause() method as well.
Copy link