Giter VIP home page Giter VIP logo

nest-event's Issues

Cannot read property 'has' of undefined

I am having issues using nest-event. I have NestEventModule imported in app.module

imports: [ NestEventModule, ... ]

Then I am injecting it in my service:
constructor(private nestEvent: NestEventEmitter)

And finally I emit an event:
this.nestEvent.emit('TESTEMIT');

This emit is triggered when I do a GET request to my API.

But all I get is this error:

error:   ┏ Cannot read property 'has' of undefined: +6ms
error:   ┃ [1] TypeError: Cannot read property 'has' of undefined
error:   ┃ [2]     at NestEventEmitter.emitter (/home/user/code/core/node_modules/nest-event/nest-event-emitter.js:42:42)
error:   ┃ [3]     at NestEventEmitter.emit (/home/user/code/core/node_modules/nest-event/nest-event-emitter.js:24:35)
error:   ┃ [4]     at UserService.test (/home/user/code/core/artifacts/dist/src/app/modules/user/services/user.service.js:45:24)
error:   ┃ [5]     at UserEventsController.readAll (/home/user/code/core/artifacts/dist/src/app/modules/user/controllers/user.events.controller.js:38:22)
error:   ┃ [6]     at /home/user/code/core/node_modules/@nestjs/microservices/context/rpc-context-creator.js:44:33
error:   ┗ [7]     at processTicksAndRejections (internal/process/task_queues.js:93:5)

It happens right here: if (!this.nestEvent.getEmitters().has(emitter)) {

I tried creating different emitter classes with @emitter() decorator but it doesn't help.
I also tried executing configure() method manually as I've seen in the code it is used for setting emitters in a Map, also doesn't help.

Any suggestions? Thanks in advance

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.