Skip to content

Commit f0987f6

Browse files
authored
feat: types adjustments (#3)
1 parent f176fd4 commit f0987f6

File tree

4 files changed

+7
-6
lines changed

4 files changed

+7
-6
lines changed

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "nest-events",
3-
"version": "2.0.3",
3+
"version": "2.0.5",
44
"private": false,
55
"license": "MIT",
66
"repository": {
@@ -22,7 +22,7 @@
2222
"scripts": {
2323
"build": "tsc --project tsconfig-build.json",
2424
"prebuild": "npx rimraf dist",
25-
"prepublish": "npm run build",
25+
"prepublishOnly": "npm run build",
2626
"lint": "eslint \"{src}/**/*.ts\" --fix",
2727
"test": "jest",
2828
"test:watch": "jest --watch",

src/definitions.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@ import { Inject, Optional } from '@nestjs/common';
22
import { ConstructorOptions, EventEmitter2 } from 'eventemitter2';
33

44
export type IEventEmitter = Pick<EventEmitter2, 'emitAsync' | 'on' | 'off'>;
5+
export const Options = Symbol('EventBusModuleOptions');
56

67

78
export class DefaultEventEmitter extends EventEmitter2 implements IEventEmitter {
8-
constructor(@Optional() @Inject('Options') options?: ConstructorOptions) {
9+
constructor(@Optional() @Inject(Options) options?: ConstructorOptions) {
910
super(options);
1011
}
1112
}

src/eventbus.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export class EventBus {
1010
return await this.emitter().emitAsync(event, ...args);
1111
}
1212

13-
public emitter(emitter: string = 'default'): IEventEmitter | undefined {
13+
public emitter(emitter: string = 'default'): IEventEmitter {
1414
if (this.module.getEmitters().has(emitter)) {
1515
return this.module.getEmitters().get(emitter);
1616
}

src/module.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { DynamicModule, Module } from '@nestjs/common';
22
import { DiscoveryModule } from '@nestjs/core';
33
import { ConstructorOptions } from 'eventemitter2';
4-
import { DefaultEventEmitter } from './definitions';
4+
import { DefaultEventEmitter, Options } from './definitions';
55
import { EventBus } from './eventbus';
66
import { EventBusInitializer } from './initializer';
77

@@ -23,7 +23,7 @@ export class EventBusModule {
2323
module: EventBusModule,
2424
imports: [DiscoveryModule],
2525
providers: [
26-
{ provide: 'Options', useValue: options },
26+
{ provide: Options, useValue: options },
2727
EventBusInitializer,
2828
EventBus,
2929
DefaultEventEmitter

0 commit comments

Comments
 (0)