summaryrefslogtreecommitdiff
path: root/ui/lib/state/remote/users.svelte.js
blob: 391ab3a637071090e169f46747906234e1646eee (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
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(new SvelteMap());

  add({ id, name }) {
    this.all.set(id, new User(id, name));
  }
}