fix: allow multiple visuals for the same pattern

+ using .tag function instead of single .id
This commit is contained in:
Felix Roos 2024-03-28 09:31:12 +01:00
parent ab015ff48a
commit b5720355f9
5 changed files with 15 additions and 11 deletions

View file

@ -2477,13 +2477,13 @@ export const hsl = register('hsl', (h, s, l, pat) => {
});
/**
* Sets the id of the hap in, for filtering in the future.
* @name id
* Tags each Hap with an identifier. Good for filtering. The function populates Hap.context.tags (Array).
* @name tag
* @noAutocomplete
* @param {string} id anything unique
* @param {string} tag anything unique
*/
Pattern.prototype.id = function (id) {
return this.withContext((ctx) => ({ ...ctx, id }));
Pattern.prototype.tag = function (tag) {
return this.withContext((ctx) => ({ ...ctx, tags: (ctx.tags || []).concat([tag]) }));
};
//////////////////////////////////////////////////////////////////////