Merge commit '63eb912434' into notes-and-numbers

This commit is contained in:
Felix Roos 2022-02-28 22:56:25 +01:00
commit 9b3f77f4f5
29 changed files with 22191 additions and 20121 deletions

View file

@ -183,7 +183,7 @@ class Hap {
this.context = context
this.stateful = stateful
if (stateful) {
assert(typeof this.value === "function", "Stateful values must be functions");
console.assert(typeof this.value === "function", "Stateful values must be functions");
}
}
@ -206,9 +206,10 @@ class Hap {
resolveState(state) {
if (this.stateful && this.hasOnset()) {
console.log("stateful")
const func = this.value
[newState, newValue] = func(state)
return [newState, this.withValue(() => newValue)]
const [newState, newValue] = func(state)
return [newState, new Hap(this.whole, this.part, newValue, this.context, false)]
}
return [state, this]
}