Skip to content

Instantly share code, notes, and snippets.

@ssougnez
Last active March 11, 2021 22:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ssougnez/6a777d367fb3498a241710fe0c83c30f to your computer and use it in GitHub Desktop.
Save ssougnez/6a777d367fb3498a241710fe0c83c30f to your computer and use it in GitHub Desktop.
import { HttpClient } from '@angular/common/http';
import { Component, OnInit } from '@angular/core';
import { interval } from 'rxjs';
import { map, takeUntil } from 'rxjs/operators';
import { BaseComponent } from './base-component';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.scss']
})
export class AppComponent extends BaseComponent implements OnInit {
constructor(private _http: HttpClient) {
super();
}
public ngOnInit() {
interval(1000)
.pipe(
takeUntil(this.destroy$),
map(() => this._http.put('http://localhost:3000/documents/1', { lastUpdate: new Date() }))
)
.subscribe(() => console.log('Document saved!'));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment