Skip to content

Commit

Permalink
Minor changes - working on DI for event management.
Browse files Browse the repository at this point in the history
  • Loading branch information
AdamKyle committed Nov 18, 2023
1 parent 044e8b7 commit c611e69
Show file tree
Hide file tree
Showing 4 changed files with 1,076 additions and 905 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@
"rpg-awesome": "^0.2.0",
"styled-components": "^5.3.3",
"tailwindcss-classnames": "^3.0.2",
"tsyringe": "^4.8.0",
"uuid": "^8.3.2"
}
}
Binary file modified resources/data-imports/Admin Section/guide_quests.xlsx
Binary file not shown.
49 changes: 49 additions & 0 deletions resources/js/game/lib/containers/core-container.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@

import {container} from 'tsyringe';

class CoreContainer {

private static instance: CoreContainer;

private constructor() {

}

/**
* Get an instance of the container.
*/
static getInstance() {
if (!CoreContainer.instance) {
CoreContainer.instance = new CoreContainer();
}
return CoreContainer.instance;
}

/**
* Fetch dependency
*
* Throws is the dependency does not exist.
*
* @param key
* @throws Error
*/
public fetch<T>(key: string): T {
const service = container.resolve<T>(key);

if (!service) {
throw new Error(`Service not found: ${key}`);
}

return service;
}

/**
* Register a dependency with the container.
*
* @param key
* @param service
*/
register<T>(key: string, service: T): void {
container.register(key, { useValue: service });
}
}
Loading

0 comments on commit c611e69

Please sign in to comment.