스로틀 방출에 따라 버퍼 방출을 생성하려고합니다.rxjs 버퍼가 저의 예상대로 스로틀에서 작동하지 않습니다
.buffer(function() { return clickStream.throttle(250); })
하지만 그것은 다음과 같은 오류를 반환 내 로컬 프로젝트에서이를 사용하려고 할 때 : 다음 작품 RxJs 2에서 예상대로 여기
Uncaught TypeError: You provided '() => clickStream.throttle(250)' where a stream was expected. You can provide an Observable, Promise, Array, or Iterable.
을 내 코드
import Rx from 'rxjs/Rx';
const $button = document.getElementById('button');
const $label = document.getElementById('label');
const clickStream = Rx.Observable.fromEvent($button, 'click');
const doubleClickStream = clickStream
.buffer(() => clickStream.throttle(250))
.map(arr => arr.length)
.filter(len => len === 2)
clickStream.subscribe(x=>console.log(x));
doubleClickStream
.subscribe(() => $label.textContent = 'double click')
//
doubleClickStream
.throttle(1000)
.subscribe(() => $label.textContent = '-')
이 라이브러리에 대한 나의 현재 지식이 충분하지 않다는 것을 알 수 있습니다. 아마도 rxjs 버전과 관련이 있습니다 (작업 예제에서는 2.x이고 위 코드는 5.x 임).
은 또한으로 작성했습니다 :
.buffer(clickStream.throttle(250))
그리고 버튼을 클릭 한 후 다른 예외를 제기 :
Uncaught TypeError: this.durationSelector is not a function
당신이 날은 그게 잘못 이해하는 데 도움이 수 있습니까?
'throttle' 대신 [throttleTime] (http://reactivex.io/rxjs/class/es6/Observable.js~Observable.html#instance-method-throttleTime)을 사용하십시오. –
.buffer (clickStream.throttleTime 250))해야한다. –