Filter operator of RxJS (Angular environment)

a take operator

Emits only the N values ​​(N = ) originally emitted by the source Observable  count. If the number of values ​​emitted by the source is less than  count , then all of its values ​​will be emitted. Then it completes, whether or not the source Observable completes.

import { Component, OnInit } from '@angular/core';
import { range } from 'rxjs/observable/range';
import { take } from 'rxjs/operators/take';

@Component({
  selector: 'app-filter',
  templateUrl: './filter.component.html' ,
  styleUrls: ['./filter.component.css']
})
export class FilterComponent implements OnInit {

  constructor() { }

  by OnInit () {
    range(100, 10)
      .pipe(take(5))
      .subscribe(val => {
        console.log(val);
      });
  }

}

 

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325045331&siteId=291194637