Open History to see the last commit
1export async function sleep(ms: number) {
2 return new Promise((res) => setTimeout(res, ms))
3}
4β
5export interface StoredUser {
6 firstName: string
7 lastName: string
8}
9β
10class DB {
11 private data: StoredUser
12β
13 constructor() {
14 this.data = { firstName: 'FirstName', lastName: 'LastName' }
15 }
16β
17 async getData(): Promise<StoredUser> {
18 await sleep(1000)
19 return { ...this.data }
20 }
21β
22 async saveUser(value: StoredUser) {
23 await sleep(1000)
24 this.data = value
25 return value
26 }
27}
28β
29/**
30 * Dummy Database to emulate server-side actions
31 */
32export const db = new DB()