Skip to content

Instantly share code, notes, and snippets.

View saptarshibasu's full-sized avatar

Saptarshi Basu saptarshibasu

View GitHub Profile
@saptarshibasu
saptarshibasu / keybase.md
Created October 24, 2018 15:47
Keybase Proof

Keybase proof

I hereby claim:

  • I am saptarshibasu on github.
  • I am saptarshibasu (https://keybase.io/saptarshibasu) on keybase.
  • I have a public key ASAmhJS0sCqF3Pqomoqlu1tWzS5L7571AXAfLOX2rvapZQo

To claim this, I am signing this object:

@saptarshibasu
saptarshibasu / post.service.ts
Last active August 29, 2018 03:40
[Caching API Response Using RxJS] Sometimes REST API is called to fetch static data (e.g. a list of all countries, states etc.) from the server. Such API response should be cached to avoid any future call to the API and thus improving performance. In the following code, shareReplay RxJS operator is used to cache the last api response and return …
import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { retryWhen, delay, tap, scan, concatMap, shareReplay, share } from 'rxjs/operators';
@Injectable({
providedIn: 'root'
})
export class PostService {
private posts;
@saptarshibasu
saptarshibasu / google-device-auth.service.ts
Last active August 29, 2018 03:41
[User Authentication Using Google OAuth 2.0 APIs for TVs & Devices] This is an Angular service that invokes the Google APIs to authenticate a user in an app that doesn't run on a browser, for e.g. a desktop app. This service uses RxJS to retry the REST API calls at a specific interval in case of failure due to unstable internet connection. #Angu…
import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { retryWhen, delay, tap, scan, concatMap } from 'rxjs/operators';
@Injectable({
providedIn: 'root'
})
export class GoogleDeviceAuthService {
private readonly client_id = "<client-id>";