Skip to content

Commit

Permalink
feat: remove registry freezing
Browse files Browse the repository at this point in the history
  • Loading branch information
paradoxuum committed Dec 23, 2023
1 parent 120f5a0 commit 0a31bc3
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 15 deletions.
2 changes: 0 additions & 2 deletions src/client/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,6 @@ export namespace CommanderClient {

callback(registryInstance);
await registryInstance.sync();

registryInstance.freeze();
started = true;

if (options.app !== undefined) {
Expand Down
1 change: 0 additions & 1 deletion src/server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ export namespace CommanderServer {
dispatcherInstance.init();
registryInstance.init(optionsObject);
callback(registryInstance);
registryInstance.freeze();
started = true;
}

Expand Down
12 changes: 0 additions & 12 deletions src/shared/core/registry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ export abstract class BaseRegistry {
protected readonly types = new Map<string, TypeOptions<defined>>();
protected readonly registeredObjects = new Set<object>();
protected cachedPaths = new Map<string, CommandPath[]>();
protected frozen = false;

protected registerBuiltInTypes() {
const builtInTypes =
Expand All @@ -28,20 +27,12 @@ export abstract class BaseRegistry {
this.registerContainer(builtInTypes);
}

/**
* Freezes the registry, preventing any further registration.
*/
freeze() {
this.frozen = true;
}

/**
* Registers a type from a given {@link TypeOptions}.
*
* @param typeOptions The type to register
*/
registerType<T extends defined>(typeOptions: TypeOptions<T>) {
assert(!this.frozen, "Registry frozen");
this.types.set(typeOptions.name, typeOptions);
}

Expand All @@ -51,7 +42,6 @@ export abstract class BaseRegistry {
* @param types The types to register
*/
registerTypes(...types: TypeOptions<defined>[]) {
assert(!this.frozen, "Registry frozen");
for (const options of types) {
this.registerType(options);
}
Expand All @@ -64,7 +54,6 @@ export abstract class BaseRegistry {
* @param container The container containing {@link ModuleScript}s
*/
registerContainer(container: Instance) {
assert(!this.frozen, "Registry frozen");
for (const obj of container.GetChildren()) {
if (!obj.IsA("ModuleScript")) {
continue;
Expand All @@ -88,7 +77,6 @@ export abstract class BaseRegistry {
* @param container The {@link Instance} containing commands
*/
registerCommandsIn(container: Instance) {
assert(!this.frozen, "Registry frozen");
for (const obj of container.GetChildren()) {
if (!obj.IsA("ModuleScript")) {
return;
Expand Down

0 comments on commit 0a31bc3

Please sign in to comment.