mirror of https://github.com/ghostfolio/ghostfolio
6 changed files with 96 additions and 57 deletions
@ -0,0 +1,9 @@ |
|||||
|
import { AssetProfileIdentifier } from '@ghostfolio/common/interfaces'; |
||||
|
|
||||
|
export class MarketDataUpdatedEvent { |
||||
|
public constructor(public readonly data: AssetProfileIdentifier) {} |
||||
|
|
||||
|
public static getName(): string { |
||||
|
return 'market-data.updated'; |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,25 @@ |
|||||
|
import { DataProviderService } from '@ghostfolio/api/services/data-provider/data-provider.service'; |
||||
|
import { ExchangeRateDataService } from '@ghostfolio/api/services/exchange-rate-data/exchange-rate-data.service'; |
||||
|
|
||||
|
import { Injectable } from '@nestjs/common'; |
||||
|
import { OnEvent } from '@nestjs/event-emitter'; |
||||
|
|
||||
|
import { MarketDataUpdatedEvent } from './market-data-updated.event'; |
||||
|
|
||||
|
@Injectable() |
||||
|
export class MarketDataUpdatedListener { |
||||
|
public constructor( |
||||
|
private readonly dataProviderService: DataProviderService, |
||||
|
private readonly exchangeRateDataService: ExchangeRateDataService |
||||
|
) {} |
||||
|
|
||||
|
@OnEvent(MarketDataUpdatedEvent.getName()) |
||||
|
public handleMarketDataUpdated(event: MarketDataUpdatedEvent) { |
||||
|
if ( |
||||
|
event.data.dataSource === |
||||
|
this.dataProviderService.getDataSourceForExchangeRates() |
||||
|
) { |
||||
|
this.exchangeRateDataService.invalidateCache(event.data.symbol); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
Loading…
Reference in new issue