[RxJS] Avoid mulit post requests by using shareReplay()
by Using post requests Rxjs avoid
2023-09-14 09:00:51 时间
With the shareReplay
operator in place, we would no longer fall into the situation where we have accidental multiple HTTP requests.
And this covers the main use cases for doing the most typical read and modification operations, that we would implement while doing a custom REST API.
import 'rxjs/add/operator/shareReplay'; signUp(email: string, password: string) { return this.http.post<User>('/api/signup', { email, password }).shareReplay() // make sure that request was cached and it return observable .do((user) => this.subject.next(user)); }
shareReplay was added to RxJS V5.4
More informaiton about shareReplay.
相关文章
- SQL中Group By的使用详解
- group by
- [AWS] ElasticSearch, Sync data between DynamoDB and ElasticSearch by using DyanmoDB Stream
- [Javascript Crocks] Make your own functions safer by lifting them into a Maybe context
- [React] Preventing extra re-rendering with function component by using React.memo and useCallback
- [Angular] Dynamic component rendering by using *ngComponentOutlet
- [React] Remove React PropTypes by using Flow Annotations (in CRA)
- [Javascript] Destructuring array by using object syntax
- [ARIA] Group different DOM element in screen reader by using aria-labelledby
- [Algorithm] Fibonacci problem by using Dynamic programming
- [Angular] Dynamic component rendering by using *ngComponentOutlet
- [Angular] Implement a custom form component by using control value accessor
- [Heroku + MySQL Workbench] Remote connection to Heroku ClearDB by using MySQL Workbench
- FreeSWITCH G.729 module using the opensource bcg729 implementation by Belledonne Communications
- ETAG is returned by the first read
- SQL GROUP BY 语句
- 已解决:Caused by: java.lang.IllegalStateException: Only one AsyncConfigurer may exist
- 全网详细解决Client does not support authentication protocol requested by server;consider upgrading Mysql c
- BaiduMap_SDK_DEMO_3.0.0_for_Xamarin.Android_by_imknown
- Caused by: java.net.ConnectException: Connection refused/Caused by: java.lang.RuntimeException: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure
- SQL中GROUP BY子句相关约束
- 第10讲:DQL数据查询语句之ORDER BY排序查询示例
- SQL group by底层原理——本质是排序,可以利用索引事先排好序
- ActiveReports.NET 17.0 Crack by Xacker
- RadiAnt DICOM Viewer Crack by Xacker