Watcher data structure

v0.x.x

The structure above represents the data required to create a watcher in v0.x.x.
Watcher shape can only be a rectangle. Passing extra information to Lampix can only be done through the .classifier prop via the parameters sent in an inline string.

Registered watcher object

lampix.watchers.add(w1, w2, ..., wN) returns a Promise that resolves with N objects through which the newly added watchers can be managed.

The registered watcher object provides convenience features such as .remove(), .pause() and .resume().
The information used to create the registered watcher can be found in the .source prop of the registered watcher object.

See the API reference for more information.

lampix.watchers.add(w1, w2).then((rw1, rw2)=>{

// Now that we can safely use these watchers, let's pause them

rw1.pause();// pause indefinitely

rw2.pause(5000);// pause for 5 seconds only

});

Watcher index no longer necessary

v0.x.x provides the index of the watcher where movement is detected along with other relevant information (classes, outlines, metadata), but it is up to the user to always remember what watcher corresponds to a particular index in order to perform custom actions per watcher.

v1.x.x fixes this issue by allowing the user to add an .onClassification property on watchers either on the source data for the watcher or on the registered watcher itself.

// ===== v1.x.x =====

​

const w1 ={

...,

onClassification:()=> console.log('Action specific to w1');

}

​

const w2 ={

...

// This one gets no onClassification prop

};

​

lampix.watchers.add(w1, w2).then((rw1, rw2)=>{

// Setting onClassification handler for the second watcher at a later time