[RxJS] Implement RxJS `concatMap` by Waiting for Inner Subscriptions to Complete
for to by Rxjs Complete waiting Implement INNER
2023-09-14 09:00:49 时间
Unlike mergeMap
and switchMap
, concatMap
focuses on when "inner" subscriptions "complete" by using a "buffer". Each time concatMap
receives a value, it adds each value to a "buffer", waits for previous "inner" subscription to complete
, then invokes next
with the next value from the "buffer".
class MyConcatMapSubscriber extends Subscriber { innerSubscription; buffer = []; constructor(sub, fn) { super(sub); this.fn = fn; } _next(value) { const { isStopped } = this.innerSubscription || { isStopped: true }; if (!isStopped) { this.buffer = [...this.buffer, value]; } else { const o$ = this.fn(value); this.innerSubscription = o$.subscribe({ next: value => { this.destination.next(value); }, complete: () => { if (this.buffer.length) { const { first, ...rest } = this.buffer; this.buffer = rest; this._next(first); } } }); } } }
相关文章
- 【Maven错误】 Non-resolvable parent POM for ...... Return code is: 500 , ReasonPhrase:Internal Server Error. and 'parent.relativePath' points at no local POM @ line 14, column 11
- Write on ……… failed: 112(failed to retrieve text for this error. Reason: 15105)
- 打成Jar包后运行报错 Unable to locate Spring NamespaceHandler for XML schema namespace
- [Angular] 'providedIn' for service
- Another app is currently holding the yum lock; waiting for it to exit
- [Typescript] Get a TypeScript package ready for release to NPM
- [Tools] API Extractor Setup for Typescript
- SAP技术 - How to create a CDS redirect view for a given database table
- SSR rendering exceeded timeout 3000, fallbacking to CSR for
- why CRMFSH01 failed to return any value for my case
- Spire.Doc for Java 10.12.2 update Word to PDF/HTML to Word
- Spire.Office for Java 7.11.2 - 2022-11-16
- Paper:《Explainable AI for Trees: From Local Explanations to Global Understanding树类的可解释性:从局部解释到全局理解》翻
- 成功解决xgboost.core.XGBoostError: b‘value 0 for Parameter num_class should be greater equal to 1‘
- 成功解决NotFoundError (see above for traceback): Failed to create a directory: ; No such file or directo
- mysql的auto_incremnet操作 解决Invalid default value for ‘xxx‘的问题 查询表结构
- java.net.ConnectException: Call From slaver1/192.168.19.128 to slaver1:8020 failed on connection exception: java.net.ConnectException: Connection refused; For more details see: http://wiki.apache.org
- 谣言检测——(GCAN)《GCAN: Graph-aware Co-Attention Networks for Explainable Fake News Detection on Social Media》
- 【无标题】Non-parametric test for difference in mean
- 46. Permutations——本质和树DFS遍历无异 fun: for i in nums fun(i)
- Warning: (3719, “‘utf8’ is currently an alias for the character set UTF8MB3, which will be replaced by UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous.”)
- TatukGIS 11.71 for .NET TatukGIS-2022-10-28