Adds Event system and automatic messages
This commit is contained in:
parent
0e10ea3cab
commit
2f826fbf36
20 changed files with 428 additions and 18 deletions
|
|
@ -1,15 +1,17 @@
|
|||
import {Class} from "../types/Class";
|
||||
|
||||
export class Container {
|
||||
static instance: Container;
|
||||
|
||||
private instances: Map<string, object> = new Map();
|
||||
|
||||
public set<T extends {constructor: {name: string}}>(instance: T, name: string|null = null): void
|
||||
public set<T extends Class>(instance: T, name: string|null = null): void
|
||||
{
|
||||
const settingName = name ?? instance.constructor.name;
|
||||
this.instances.set(settingName.toLowerCase(), instance);
|
||||
}
|
||||
|
||||
public get<T>(name: string): T
|
||||
public get<T extends Class>(name: string): T
|
||||
{
|
||||
return <T>this.instances.get(name.toLowerCase());
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue