Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(server): remove unused on method #13830

Merged
merged 1 commit into from
Oct 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion server/src/interfaces/event.interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ export type EventItem<T extends EmitEvent> = {

export interface IEventRepository {
setup(options: { services: ClassConstructor<unknown>[] }): void;
on<T extends keyof EventMap>(item: EventItem<T>): void;
emit<T extends keyof EventMap>(event: T, ...args: ArgsOf<T>): Promise<void>;

/**
Expand Down
5 changes: 2 additions & 3 deletions server/src/repositories/event.repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ export class EventRepository implements OnGatewayConnection, OnGatewayDisconnect

setup({ services }: { services: ClassConstructor<unknown>[] }) {
const reflector = this.moduleRef.get(Reflector, { strict: false });
const repository = this.moduleRef.get<IEventRepository>(IEventRepository);
const items: Item<EmitEvent>[] = [];

// discovery
Expand Down Expand Up @@ -94,7 +93,7 @@ export class EventRepository implements OnGatewayConnection, OnGatewayDisconnect

// register by priority
for (const handler of handlers) {
repository.on(handler);
this.addHandler(handler);
}
}

Expand Down Expand Up @@ -134,7 +133,7 @@ export class EventRepository implements OnGatewayConnection, OnGatewayDisconnect
await client.leave(client.nsp.name);
}

on<T extends EmitEvent>(item: EventItem<T>): void {
private addHandler<T extends EmitEvent>(item: EventItem<T>): void {
const event = item.event;

if (!this.emitHandlers[event]) {
Expand Down
1 change: 0 additions & 1 deletion server/test/repositories/event.repository.mock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { Mocked, vitest } from 'vitest';
export const newEventRepositoryMock = (): Mocked<IEventRepository> => {
return {
setup: vitest.fn(),
on: vitest.fn() as any,
emit: vitest.fn() as any,
clientSend: vitest.fn() as any,
clientBroadcast: vitest.fn() as any,
Expand Down
Loading