Skip to content

Instantly share code, notes, and snippets.

View mtelesborges's full-sized avatar

Mailson Teles Borges mtelesborges

View GitHub Profile
@mtelesborges
mtelesborges / angular-poolling.service.ts
Last active October 17, 2023 00:32
Angular Polling Service
import { Inject, Injectable, InjectionToken } from '@angular/core';
import { Observable, combineLatest, filter, interval, take, takeWhile } from 'rxjs';
// REQUEST_INTEVAL and MAX_QUANTITY_ATTEMPTS are InjectionToken
// InjectionTokens can be configured globally at the module, component or service level only once
// defines a interval in seconds to api request
export const REQUEST_INTEVAL = new InjectionToken<number>('REQUEST_INTEVAL', {
providedIn: 'root',