[RxJS] Completing a Stream with TakeWhile
with stream Rxjs
2023-09-14 08:59:20 时间
Subscribe can take three params:
subscribe( (x)=> console.log(x), err=> console.log(err), ()=> console.log('complete') );
If we want to stop the progame at some condition, so we need to notify complete function, which is the third param in subscribe.
Observable.combineLatest( timer$, input$, (timer, input)=> ({count: timer.count, text: input}) ) .takeWhile((data)=> data.count <= 3) .filter((data)=> data.count === parseInt(data.text)) .subscribe( (x)=> console.log(x), err=> console.log(err), ()=> console.log('complete') );
We can use takeWhile() function to end the program, so after the count = 3, "complete" will logout
相关文章
- [Kotlin Spring boot] Connect template with a backing bean
- [Node.js] Mock an API for Local Development in React with Mirage JS
- [SCSS] Access Theme Color Values With Sass
- [React] Handle HTTP Errors with React
- [NPM] Use npx to run commands with different Node.js versions
- [HTML5] Inlining images with SVG and data URIs
- [D3] Build an Area Chart with D3 v4
- [Nuxt] Update State with Vuex Actions in Nuxt.js
- [Angular 2] Nesting Elements in Angular 2 Components with ng-content (AKA Angular 2 Transclusion)
- [RxJS] Toggle A Stream On And Off With RxJS
- [RxJS] Handling a Complete Stream with Reduce
- [rxjs] Creating An Observable with RxJS
- [Ruby] 0. play with it a little bit
- [Compose] 9. Delay Evaluation with LazyBox
- [Angular] Control the dependency lookup with @Host, @Self, @SkipSelf and @Optional
- [Python] Indexing An Array With Another Array with numpy
- [Python] Manage Dependencies with Python Virtual Environments
- [Express] Upload Files with Express
- [Practical Git] Format commit history with git log arguments
- [RxJS] Toggle A Stream On And Off With RxJS
- [Immutable.js] Transforming Immutable Data with Reduce
- [RxJS] Stream Processing With RxJS vs Array Higher-Order Functions
- error C2338: You've instantiated std::aligned_storage<Len, Align> with an extended alignment (in other words, Align >
- Seurat DefaultAssay “integrated“ or “RNA“ with integrated dataset