28 Nest JS Events and how to do event driven development in Node Nest JS framework

Поделиться
HTML-код
  • Опубликовано: 17 ноя 2024

Комментарии • 27

  • @ryankim5508
    @ryankim5508 2 года назад +3

    You can use class constructor to initialize class member variables when you create the instance of the class. Thank you for informative tutorials by the way :).
    ex)
    export class ResponseAddEvent {
    constructor(private userId: number, private optionId: number) {}
    }
    ----
    @Post()
    async handleQuestionResponse() {
    // insert data into the response table
    console.log('controller');
    this.eventEmitter.emit(
    events.RESPONSE_SUBMITTED,
    new ResponseAddEvent(1, 3), // userId, optionId
    );
    return { message: 'Response taken' };
    }

  • @facundolucero5386
    @facundolucero5386 2 года назад +1

    how can this events trigger an server side event?? using rxjs to push an event to te client?

    • @amitavroydev
      @amitavroydev  2 года назад

      This is entirely server side my friend

  • @jazimabbas8168
    @jazimabbas8168 Год назад

    Which VSCODE theme are you using? Can anyone please tell me??

  • @tom_c
    @tom_c Год назад

    Great video! Trying to reproduce the events in one of my projects, I encountered a problem... The event is only emitted once, but the OnEvent listener is firing twice. Any idea why??

    • @amitavroydev
      @amitavroydev  Год назад

      That’s strange. Ideally it should not happen but it’s difficult to say what exactly is the problem without looking at the code

    • @tom_c
      @tom_c Год назад

      @@amitavroydev thank you for the response! After a bit of digging around, I found out that it is due to circular imports of services... No circular dependencies error though. I would love to hop on a short call and show you the code :) No fix found yet

    • @amitavroydev
      @amitavroydev  Год назад

      Can you share the code using github?

    • @tom_c
      @tom_c Год назад +1

      @@amitavroydev I would love to, but sadly it is a project we are currently working on in our company. I'll try to creat a new nest project and reproduce it so that you can also play around with it. Sounds good?

    • @amitavroydev
      @amitavroydev  Год назад

      Sounds good

  • @MateusSiil
    @MateusSiil Год назад

    how to do e2e test on this?

    • @amitavroydev
      @amitavroydev  Год назад

      I haven't tried e2e with Nest. So, won't be able to help you in that.

  • @skyzane2735
    @skyzane2735 Год назад

    What is the theme in vscode that you are using? I want to try that!

    • @amitavroydev
      @amitavroydev  Год назад

      Hmm.. I keep changing.. however, if I am not wrong this is Github Dark or it will me Material theme dark.

  • @ms0615122
    @ms0615122 2 года назад

    Need to add a constructor in ResponseAddEvent, then you can initialize the class in one line.

    • @amitavroydev
      @amitavroydev  2 года назад

      Can you share an example. Sorry, I don’t think I completely understand what you are saying

    • @ms0615122
      @ms0615122 2 года назад

      export class ResponseAddEvent {
      constructor(userId,optionId){}
      userId
      optionId
      }
      Then you can do
      new ResponseAddEvent(userId, optionId)

    • @ms0615122
      @ms0615122 2 года назад

      *The problem that you’re trying to solve the last 2 mins in your tutorial.

  • @himanshusuman4227
    @himanshusuman4227 2 года назад

    which theme are you using for vs code?

  • @NhileshABaua
    @NhileshABaua 2 года назад

    This makes sense, however you need to clarify that you're blending CQRS with microservices.

    • @MikeyUchiha
      @MikeyUchiha 2 года назад +1

      He isn’t using Microservices

    • @amitavroydev
      @amitavroydev  Год назад +1

      Yeah, I am not using Microservices.