rxjs

subscribe method is not triggered with RxJS

别说谁变了你拦得住时间么 提交于 2019-12-11 08:02:13
问题 I'm quite a beginner in RxJS, I'm currently using RxJS@5 and don't understand a behavior of my code const currentExtentMinutes$ = initialExtentMinutes$ .merge(selectedExtentMinutes$) .distinctUntilChanged() // We message the worker that // there is a new extent minutes currentExtentMinutes$ .subscribe(currentExtentMinutes => { console.log('send current extent', currentExtentMinutes); currentExtentMinutes => worker.postMessage({currentExtentMinutes}); }); This works great, but as soon as I add

Does startWith() operator turns Observable into ReplaySubject(1)?

守給你的承諾、 提交于 2019-12-11 07:58:26
问题 If I want subscribers to initially get at least X , can I use startWith( X ) for an existing Observable: streamFromLibrary.startWith( X ).subscribe( myHandler ); //I want myHandler() to not wait until streamFromLibrary produce a value //but be called instantly with X or it still needs to be carried through intermediate ReplaySubject( 1 ) like this? let carrier = new Rx.ReplaySubject( 1 ); carrier.next( X ); streamFromLibrary.subscribe( value => carrier.next( value ) ); carrier.subscribe(

RxJS wait for previous execution to finish

喜夏-厌秋 提交于 2019-12-11 07:49:21
问题 Ok, so I'm new to RxJs and I can't figure out some thing. I need to implement image processing in which the user adds multiple images at a time and for each image, among others, following actions must occur: Generate the image thumbnail in the web worker Upload the image and a thumbnail to the server But I don't want all thumbnails to be generated at once, I'd like them to generate sequentially. Here's what I tried: https://codesandbox.io/s/funny-mountain-tm0jj?expanddevtools=1&fontsize=14 I

How to handle open ended pagination using reactive streams?

丶灬走出姿态 提交于 2019-12-11 07:36:46
问题 I am using RxJS for all async request handling in my redux application. One thing in particular I am using it for is enumerating all the results from a paginated AWS API. Those APIs generally do not allow random page jumping, one must call the API with a special token ( nextToken ) from the previous call and follow the sequence. The list is complete when there is no nextToken sent with the response. What I would like to do is have a stream of the partial page results that I can at the end

Angular 2 array after subscribe has elements but length is 0

此生再无相见时 提交于 2019-12-11 07:23:18
问题 I'm using Angular 2 and I have noticed an unexpected behaviour. I have a datasource class, which extends DataSource, with two variables: private archives = new BehaviorSubject<MyArchive[]>([]); public archives$: Observable<MyArchive[]> = this.archives.asObservable(); private filteredArchive: MyArchive[]; I update archives this way within the class: this.archives.next(this.filteredArchive); Outside in another class I try to subscribe to the observable but it doesn't work: ngAfterViewInit():

How to split a data frame from an arrayBuffer with RxJS?

☆樱花仙子☆ 提交于 2019-12-11 06:58:12
问题 I'm using websocket to receive data frame from hardware. The data frame is defined like this: 0xbb(head) ---data--- 0xee(tail) the received data is store in Uint8Array, there maybe multiple frame: var buffer = new Uint8Array([0xbb,0,0,0,0xee,0xbb,1,1,1,0xee,0xbb,3,3,3,0xee]); and I can convert the array to observable: var obs= Rx.Observable.from(buffer); RxMarbles: --0xbb--0--0--0--0xee--0xbb--1--1--1--0xee--0xbb--2--2--2--0xee------ ------------------000------------------111-----------------

Angular2 observables do I need to share

与世无争的帅哥 提交于 2019-12-11 06:51:22
问题 I have a form input for a search. When a user enters something in the search input I need to call 2 separate api's. This is what I'm trying to achieve: myInput: new FormControl(); listOne: Observable<string[]>; listTwo: Observable<string[]>; ngOnInit(){ this.listOne = this.myInput.valueChanges .debounceTime(500) .distinctUntilChanged() .switchMap(myInput => this._service.getListOne(myInput)); this.listTwo = this.myInput.valueChanges .debounceTime(500) .distinctUntilChanged() .switchMap

angular 2 MockBackend test http timeout?

久未见 提交于 2019-12-11 06:42:46
问题 Is there a way to test http timeout behaviour of a service? I'm using MockBackend even when setting job's timeout to 0 no logging of 'TIMEOUT' present. export class MyHttpService { private sendGetRequest (job: HttpJob): Observable<any> { return this.http.get(job.getUrl(), this.options) .share() .timeout(job.getTimeout(), () => this.requestTimeout(job)) .catch((err) => this.errorHandler(err, job)); }; private requestTimeout(job: HttpJob): Error { job.errorCode = ErrorCode.TIMEOUT; console.log(

break up buffer into size rxjs

大城市里の小女人 提交于 2019-12-11 06:37:28
问题 I have an observable get data from stream each time at size 512 each next I have to break it up to 200 char at other observable and keep [12] char in other buffer to concatenate with next block, I solve it by using new subject and for loop, I believe there maybe a better, more pretty solution. received Observable ---------------------------------------- 1st next [512] -------> [112] [200] [200] -------> [200] [200] 2nd next [512][ 112 ] --> [24][200][200] [88+ 112 ] --> [200] [200] 3rd next

RxJS: Why is 'this' undefined within subscribe [closed]

陌路散爱 提交于 2019-12-11 06:36:42
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 2 years ago . I'm trying to setup a simple error notifications component, whilst debugging in Visual Studio, within subscribe, this appears to be undefined. public notifications: NotificationMessage[]; constructor(notificationService: NotificationService) { this.notifications = []; //'this' is defined here notificationService