Skip to content

Instantly share code, notes, and snippets.

View samteb's full-sized avatar
🎯
Focusing

Samuel samteb

🎯
Focusing
View GitHub Profile
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';
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;
import { Injectable } from '@angular/core';
import { combineLatest, Observable } from 'rxjs';
import { switchMap } from 'rxjs/operators';
import { AuthorModel } from '../../models/author.model';
import { ListService } from './list.service';
@Injectable()
export class AuthorsListService extends ListService {
public listTitle = 'Weekly best authors!';
public showNbOfArticlesDropdown = true;
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.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;
}
enum ListLevel {
AUTHORS = 'AUTHORS',
ARTICLES = 'ARTICLES'
}
interface Pagination {
first: number;
last: number;
}
class Node {
constructor (value, priority) {
this.value = value;
this.priority = priority;
}
}
class PriorityQueue {
constructor () {
this.values = [];
class Graph {
constructor () {
this.adjacencyList = {};
}
addVertex (vertex) {
if (!this.adjacencyList[vertex]) this.adjacencyList[vertex] = [];
}
addEdge (vertex1, vertex2) {
class Node {
constructor (value, priority) {
this.value = value;
this.priority = priority;
}
}
class PriorityQueue {
constructor () {
this.values = [];
class MaxBinaryHeap {
constructor () {
this.values = [];
}
insert (value) {
this.values.push(value);
this.bubbleUp();
}