This file contains hidden or 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
| import { Component, Injector, OnInit } from '@angular/core'; | |
| import { Observable, Subscription } from 'rxjs'; | |
| import { tap } from 'rxjs/operators'; | |
| import { ListLevel } from './models/list-level.enum'; | |
| import { ArticleModel } from './models/article.model'; | |
| import { ApiService } from './services/api.service'; | |
| import { ListService, ListType } from './services/list/list.service'; | |
| import { AuthorsListService } from './services/list/authors-list.service'; | |
| import { ArticlesListService } from './services/list/articles-list.service'; |
This file contains hidden or 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
| import { Injectable } from '@angular/core'; | |
| import { combineLatest, Observable } from 'rxjs'; | |
| import { switchMap } from 'rxjs/operators'; | |
| import { ArticleModel } from '../../models/article.model'; | |
| import { ListService } from './list.service'; | |
| @Injectable() | |
| export class ArticlesListService extends ListService { | |
| public listTitle = 'Interesting articles!'; | |
| public showNbOfArticlesDropdown = false; |
This file contains hidden or 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
| 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[]; |
This file contains hidden or 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
| this.listTitle$ = this.listLevel$.pipe( | |
| map(listLevel => { | |
| switch (listLevel) { | |
| case ListLevel.AUTHORS: | |
| return 'Trending authors that published few minutes ago!'; | |
| case ListLevel.ARTICLES: | |
| return 'Best articles for you!'; | |
| default: | |
| break; | |
| } |
This file contains hidden or 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
| enum ListLevel { | |
| AUTHORS = 'AUTHORS', | |
| ARTICLES = 'ARTICLES' | |
| } | |
| interface Pagination { | |
| first: number; | |
| last: number; | |
| } |
This file contains hidden or 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
| class Node { | |
| constructor (value, priority) { | |
| this.value = value; | |
| this.priority = priority; | |
| } | |
| } | |
| class PriorityQueue { | |
| constructor () { | |
| this.values = []; |
This file contains hidden or 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
| class Graph { | |
| constructor () { | |
| this.adjacencyList = {}; | |
| } | |
| addVertex (vertex) { | |
| if (!this.adjacencyList[vertex]) this.adjacencyList[vertex] = []; | |
| } | |
| addEdge (vertex1, vertex2) { |
This file contains hidden or 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
| class Node { | |
| constructor (value, priority) { | |
| this.value = value; | |
| this.priority = priority; | |
| } | |
| } | |
| class PriorityQueue { | |
| constructor () { | |
| this.values = []; |
This file contains hidden or 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
| class MaxBinaryHeap { | |
| constructor () { | |
| this.values = []; | |
| } | |
| insert (value) { | |
| this.values.push(value); | |
| this.bubbleUp(); | |
| } |
NewerOlder