diff --git a/packages/core/pattern.mjs b/packages/core/pattern.mjs index 737df84f..84441a1b 100644 --- a/packages/core/pattern.mjs +++ b/packages/core/pattern.mjs @@ -1046,6 +1046,22 @@ export class Pattern { onTrigger(onTrigger) { return this._withHap((hap) => hap.setContext({ ...hap.context, onTrigger })); } + log(func = id) { + return this._withHap((hap) => + hap.setContext({ + ...hap.context, + onTrigger: (...args) => { + if (hap.context.onTrigger) { + hap.context.onTrigger(...args); + } + console.log(func(...args)); + }, + }), + ); + } + logValues(func = id) { + return this.log((_, hap) => func(hap.value)); + } } // TODO - adopt value.mjs fully..