chore(project) rename main directory
This commit is contained in:
24
lib/WetSock/Models/Repository.js
Normal file
24
lib/WetSock/Models/Repository.js
Normal file
@@ -0,0 +1,24 @@
|
||||
export default class Repository {
|
||||
#entityClass = undefined;
|
||||
#actions = new Map();
|
||||
constructor(config) {
|
||||
this.#entityClass = config.entityClass;
|
||||
}
|
||||
|
||||
create(entityData) {
|
||||
return new this.#entityClass(entityData);
|
||||
}
|
||||
|
||||
perform(entity, actionName, ...args) {
|
||||
if(!this.#actions.has(actionName)) throw new Error(`Action '${actionName}' is not registered.`);
|
||||
return this.#actions.get(actionName)(entity, ...args);
|
||||
}
|
||||
|
||||
register(actionName, actionFn) {
|
||||
this.#actions.set(actionName, actionFn);
|
||||
}
|
||||
|
||||
getActions() {
|
||||
return Array.from(this.#actions.keys());
|
||||
}
|
||||
}
|
||||
19
lib/WetSock/Models/Room.js
Normal file
19
lib/WetSock/Models/Room.js
Normal file
@@ -0,0 +1,19 @@
|
||||
export default class Room {
|
||||
constructor(data) {
|
||||
this.id = data.id;
|
||||
this.name = data.name;
|
||||
this.users = new Set();
|
||||
}
|
||||
|
||||
addUser(userId) {
|
||||
this.users.add(userId);
|
||||
}
|
||||
|
||||
removeUser(userId) {
|
||||
this.users.delete(userId);
|
||||
}
|
||||
|
||||
getUsers() {
|
||||
return Array.from(this.users);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user