Rxjs - Operators - TakeLast

Signature

export declare function takeLast<T>(total: number): Observable<T>;

取出一个流中最后几个数据组成一个新的流

注意前提: 流要结束才会出数据

var many = Rx.Observable.range(1, 100);
var lastThree = many.takeLast(3);
// var lastThree = many.takeLast(-1);
lastThree.subscribe(x => console.log(x));

如果参数小于0, 会抛出exception ArgumentOutOfRangeError