blob: a15d1da0628a9cf1c3de23acfc66a403c08d3d7e (
plain)
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
32
33
|
import { SvelteMap } from 'svelte/reactivity';
export class User {
static equal(a, b) {
return a.id === b.id && a.name === b.name;
}
static boot({ id, name }) {
return new User(id, name);
}
constructor(id, name) {
this.id = id;
this.name = name;
}
}
export class Users {
all = $state();
static boot(users) {
const all = new SvelteMap(users.map((user) => [user.id, User.boot(user)]));
return new Users({ all });
}
constructor({ all }) {
this.all = all;
}
add({ id, name }) {
this.all.set(id, new User(id, name));
}
}
|