-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathRealDao.ts
52 lines (42 loc) · 1.43 KB
/
RealDao.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import { Dao } from './Dao';
import { AvailableStock } from '../state/AvailableStock';
export class RealDao extends Dao {
/**
* Read the current list of available stocks from the backend.
* Note: this demonstrates how to get one-off information from the backend.
*/
async readAvailableStocks(): Promise<AvailableStock[]> {
// TODO: Implement this method to fetch from the real backend.
throw new Error('Not yet implemented');
// Should do something like this:
// const stocks: Stock[] = await this.fetchStocks();
// return stocks;
}
/**
* Continuously get stock price updates.
* Note: this demonstrates how to get information from websockets.
*
* @param onUpdate - A callback function that gets the ticker and the new
* price of a stock.
*
* Example:
* listenToStockPriceUpdates((ticker, price) => {
* console.log(`The new price of ${ticker} is $${price}`);
* });
*/
listenToStockPriceUpdates(onUpdate: (ticker: string, price: number) => void): void {
// TODO: Implement this method to fetch from the real backend.
throw new Error('Not yet implemented');
}
/**
* Stop getting stock price updates.
* Note: this demonstrates how to close websockets.
*/
stopStockPriceUpdates(): void {
// TODO: Implement this method to fetch from the real backend.
throw new Error('Not yet implemented');
}
public toString(): string {
return 'RealDao';
}
}