-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathItem.browser.ts
31 lines (25 loc) · 1.12 KB
/
Item.browser.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import { ConnectionListener } from "async-reactivity-net";
import BaseItem from './Item.js';
import SampleLiveQuery from "./SampleLiveQuery.browser.js";
import { bindAwait } from "async-reactivity-vue";
export default class Item extends BaseItem {
readonly text: ConnectionListener<string | undefined, SampleLiveQuery>;
readonly done: ConnectionListener<boolean | undefined, SampleLiveQuery>;
readonly vue: {
id: string;
text: ReturnType<typeof bindAwait<string | undefined>>['data'];
done: ReturnType<typeof bindAwait<boolean | undefined>>['data'];
valid: ReturnType<typeof bindAwait<boolean>>['data'];
}
constructor(liveQuery: SampleLiveQuery, id: string) {
super(id);
this.text = new ConnectionListener(liveQuery, async q => q.item(id).text);
this.done = new ConnectionListener(liveQuery, async q => q.item(id).done);
this.vue = {
id,
text: bindAwait(this.text, '').data,
done: bindAwait(this.done, false).data,
valid: bindAwait(this.valid, true).data,
};
}
}