This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Component({ | |
selector: 'cf-tile', | |
templateUrl: './tile.component.html', | |
styleUrls: ['./tile.component.scss'], | |
changeDetection: ChangeDetectionStrategy.OnPush | |
}) | |
export class TileComponent { | |
@Input() tile: Tile; | |
constructor( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Injectable() | |
export class AssetsFacadeImplService implements AssetsFacadeService { | |
public assets$ = this.store.select(selectAllAssets); | |
constructor(private store: Store<EntityState<Asset>>) {} | |
getAssets() { | |
this.store.dispatch( | |
getAssetsRequestStarted({ | |
payload: [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Injectable() | |
export class DashboardFacadeServiceImpl implements DashboardFacadeService { | |
public tiles$: Observable<Tile[]> = this.store.select(selectAllTiles); | |
constructor(private store: Store<EntityAdapter<Tile>>) {} | |
addTile(payload: Tile) { | |
this.store.dispatch(addTile({ payload })); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Component({ | |
selector: 'cf-dashboard', | |
templateUrl: './dashboard.component.html', | |
styleUrls: ['./dashboard.component.scss'], | |
changeDetection: ChangeDetectionStrategy.OnPush | |
}) | |
export class DashboardComponent implements OnInit { | |
public tiles$ = this.dashboardFacade.tiles$; | |
constructor( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<mat-grid-list | |
cols="4" | |
rowHeight="2:1" | |
gutterSize="15px" | |
*ngIf="tiles$ | async as tiles" | |
> | |
<ng-container *ngFor="let tile of tiles"> | |
<mat-grid-tile class="pricer"> | |
<cf-tile [tile]="tile"></cf-tile> | |
</mat-grid-tile> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Injectable() | |
export class PricesEffects { | |
constructor( | |
private actions: Actions, | |
private coincap: CoincapService, | |
private pricesFacade: PricesFacadeService | |
) {} | |
createPriceSubscription$ = this.createPriceSubscription(); | |
prices$ = this.getPrices(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export class CoincapService { | |
// .. other methods | |
webSocket: WebSocket; | |
public connectToPriceStream(assets: string[]): Observable<PriceState> { | |
this.createConnection(assets); | |
return new Observable(observer => { | |
const webSocket = this.webSocket; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private addAssets() { | |
return createEffect(() => | |
this.actions.pipe( | |
ofType(getAssetsRequestSuccess.type), | |
map(({ payload }: { payload: Asset[] }) => | |
addAssets({ payload }) | |
) | |
) | |
); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private getAllAssets() { | |
return createEffect(() => | |
this.actions.pipe( | |
ofType(getAssetsRequestStarted.type), | |
mergeMap(({ payload }: { payload: string[] }) => | |
this.coincap.getAssets(payload).pipe( | |
map((response: GetAssetsResponseDto) => response.data), | |
catchError(() => of(undefined)) | |
) | |
), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Injectable() | |
export class AssetsEffects { | |
constructor(private actions: Actions, private coincap: CoincapService) {} | |
public getAllAssets$ = this.getAllAssets(); | |
public addAssets$ = this.addAssets(); | |
private addAssets() { | |
return createEffect(() => | |
this.actions.pipe( |