##// END OF EJS Templates
Corrected Scope.own() to cleanup the supplied object immediately when the scope is disposed already
Corrected Scope.own() to cleanup the supplied object immediately when the scope is disposed already

File last commit:

r124:fbe158a5752a default
r131:c7d9ad82b374 v1.8.1 default
Show More
state-tests.ts
27 lines | 558 B | video/mp2t | TypeScriptLexer
/ djx / src / test / ts / state-tests.ts
cin
added while, until methods to the observable interface....
r124 import { observe, stateful } from "./observable";
import * as t from "tap";
interface CounterState {
count: number;
label: "low" | "mid" | "high"
}
let set: (v: CounterState) => void = () => void (0);
const initial: CounterState = { count: 0, label: "low" };
let value = initial;
const obs = observe(stateful<CounterState>(({ next }) => {
next(initial);
set = next;
}));
set({ count: 10, label: "mid" });
obs.subscribe({
next: v => value = v
});
t.equal(value.count, 10, "State should update");
set({ count: 20, label: "high" });