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 { Injectable } from '@angular/core'; | |
import { HttpClient, HttpParams } from '@angular/common/http'; | |
import { Observable } from 'rxjs'; | |
import { map } from 'rxjs/operators'; | |
import { Planet } from './planet'; | |
@Injectable() | |
export class PlanetService { | |
constructor(private http: HttpClient) {} |
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
const Rx = require('rxjs'); | |
const long$ = Rx.Observable.interval(1000).take(4); | |
const short$ = Rx.Observable.interval(500).take(4); | |
long$ | |
.switchMap(long => short$.map(short => console.log({ long, short }))) | |
.subscribe(); | |
/** Output |
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
const Rx = require('rxjs'); | |
const long$ = Rx.Observable.interval(1000).take(4); | |
const short$ = Rx.Observable.interval(500).take(4); | |
long$ | |
.flatMap(long => short$.map(short => console.log({ long, short }))) | |
.subscribe(); | |
/** Output |
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
const Rx = require('rxjs'); | |
Rx.Observable.interval(1000) | |
.map(intervalValue => intervalValue * 2) | |
.subscribe(console.log); // 0, 2, 4, 6, 8, 10, 12, 14, 16, etc |
NewerOlder