Skip to content

Instantly share code, notes, and snippets.

@samteb
Last active December 28, 2020 08:37
Show Gist options
  • Save samteb/1d62cce38c5379bc03f9ae23914fb765 to your computer and use it in GitHub Desktop.
Save samteb/1d62cce38c5379bc03f9ae23914fb765 to your computer and use it in GitHub Desktop.
import { Injectable } from '@angular/core';
import { Observable } from 'rxjs';
import { ApiService } from '../api.service';
import { StoreService } from '../store.service';
import { PaginationModel } from '../../models/pagination.model';
import { ListLevel } from '../../models/list-level.enum';
import { AuthorModel } from '../../models/author.model';
import { ArticleModel } from '../../models/article.model';
export type ListType = AuthorModel[] | ArticleModel[];
@Injectable()
export abstract class ListService {
public listLevel$: Observable<ListLevel>;
public nbArticles$: Observable<number>;
public pagination$: Observable<PaginationModel>;
public topic$: Observable<string>;
abstract listTitle: string;
abstract showNbOfArticlesDropdown: boolean;
constructor(
protected apiService: ApiService,
protected storeService: StoreService
) {
this.listLevel$ = this.storeService.select('listLevel');
this.nbArticles$ = this.storeService.select('nbOfArticles');
this.pagination$ = this.storeService.select('pagination');
this.topic$ = this.storeService.select('topic');
}
abstract getList(): Observable<ListType>;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment