mirror of https://github.com/ghostfolio/ghostfolio
Thomas Kaul
9 months ago
committed by
GitHub
13 changed files with 165 additions and 25 deletions
@ -0,0 +1,8 @@ |
|||
import { Module } from '@nestjs/common'; |
|||
|
|||
import { PortfolioChangedListener } from './portfolio-changed.listener'; |
|||
|
|||
@Module({ |
|||
providers: [PortfolioChangedListener] |
|||
}) |
|||
export class EventsModule {} |
@ -0,0 +1,15 @@ |
|||
export class PortfolioChangedEvent { |
|||
private userId: string; |
|||
|
|||
public constructor({ userId }: { userId: string }) { |
|||
this.userId = userId; |
|||
} |
|||
|
|||
public static getName() { |
|||
return 'portfolio.changed'; |
|||
} |
|||
|
|||
public getUserId() { |
|||
return this.userId; |
|||
} |
|||
} |
@ -0,0 +1,15 @@ |
|||
import { Injectable, Logger } from '@nestjs/common'; |
|||
import { OnEvent } from '@nestjs/event-emitter'; |
|||
|
|||
import { PortfolioChangedEvent } from './portfolio-changed.event'; |
|||
|
|||
@Injectable() |
|||
export class PortfolioChangedListener { |
|||
@OnEvent(PortfolioChangedEvent.getName()) |
|||
handlePortfolioChangedEvent(event: PortfolioChangedEvent) { |
|||
Logger.log( |
|||
`Portfolio of user with id ${event.getUserId()} has changed`, |
|||
'PortfolioChangedListener' |
|||
); |
|||
} |
|||
} |
Loading…
Reference in new issue