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
| interval(1000) | |
| .pipe( | |
| takeUntil(this.destroy$), | |
| map(() => this._http.put('http://localhost:3000/documents/1', { lastUpdate: new Date() }).subscribe()) | |
| ) | |
| .subscribe(x => console.log(x)); |
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 { 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'] |
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 { BrowserModule } from '@angular/platform-browser'; | |
| import { NgModule } from '@angular/core'; | |
| import { HttpClientModule } from '@angular/common/http'; | |
| import { AppComponent } from './app.component'; | |
| @NgModule({ | |
| declarations: [ | |
| AppComponent | |
| ], |
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
| { | |
| "documents": [ | |
| { | |
| "id": "1", | |
| "lastUpdate": null | |
| } | |
| ] | |
| } |
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 { interval, Observable } from 'rxjs'; | |
| import { take } from 'rxjs/operators'; | |
| const observable$: Observable<number> = interval(1000); | |
| observable$ | |
| .pipe( | |
| take(1) | |
| ) | |
| .subscribe(x => console.log(x)); |
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
| <ng-container *ngIf="data$ | async as user; else loading"> | |
| <div>First name: {{ user.firstName }}</div> | |
| <div>Last name: {{ user.lastName }}</div> | |
| <div>Age name: {{ user.age | number }}</div> | |
| </ng-container> | |
| <ng-template #loading>Loading...</ng-template> |
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
| <ng-container *ngIf="data$ | async as user"> | |
| <div>First name: {{ user.firstName }}</div> | |
| <div>Last name: {{ user.lastName }}</div> | |
| <div>Age name: {{ user.age | number }}</div> | |
| </ng-container> |
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
| <div>First name: {{ (data$ | async).firstName }}</div> | |
| <div>Last name: {{ (data$ | async).lastName }}</div> | |
| <div>Age name: {{ ((data$ | async).age) | number }}</div> |
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, Input } from '@angular/core'; | |
| import { Observable } from 'rxjs'; | |
| @Component({ | |
| selector: 'app-user', | |
| templateUrl: './user.component.html', | |
| styleUrls: ['./user.component.scss'] | |
| }) | |
| export class UserComponent { |
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, Input, OnInit } from '@angular/core'; | |
| import { Observable } from 'rxjs'; | |
| @Component({ | |
| selector: 'app-user', | |
| templateUrl: './user.component.html', | |
| styleUrls: ['./user.component.scss'] | |
| }) | |
| export class UserComponent implements OnInit { |