Skip to content

Commit 9573fa8

Browse files
committed
Tab repository as singleton
1 parent 20e2288 commit 9573fa8

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed
Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,18 @@
11
import { ITabsRepository } from "./tabs-repository-interface";
22
import { TabsRepository } from "./tabs-repository";
33

4+
let instanse: ITabsRepository | null = null;
5+
6+
async function createAndInitInstance() {
7+
let repo = new TabsRepository();
8+
await repo.initAsync();
9+
return repo;
10+
}
11+
412
export async function injectTabsRepository(): Promise<ITabsRepository> {
5-
const repo = new TabsRepository();
6-
await repo.initAsync();
7-
return repo;
8-
}
13+
if (instanse == null) {
14+
console.log("test");
15+
instanse = await createAndInitInstance();
16+
}
17+
return instanse;
18+
}

0 commit comments

Comments
 (0)