refactor onTrigger

This commit is contained in:
Felix Roos 2022-11-12 20:17:57 +01:00
parent 5fc8f10602
commit b668a2c0d2
6 changed files with 122 additions and 141 deletions

View file

@ -32,11 +32,8 @@ function speak(words, lang, voice) {
}
Pattern.prototype._speak = function (lang, voice) {
return this._withHap((hap) => {
const onTrigger = (time, hap) => {
speak(hap.value, lang, voice);
};
return hap.setContext({ ...hap.context, onTrigger });
return this.onTrigger((_, hap) => {
speak(hap.value, lang, voice);
});
};