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.

[RxJS] Avoid mulit post requests by using shareReplay()的更多相关文章

  1. [RxJS] Reactive Programming - New requests from refresh clicks -- merge()

    Now we want each time we click refresh button, we will get new group of users. So we need to get the ...

  2. [Vue-rx] Disable Buttons While Data is Loading with RxJS and Vue.js

    Streams give you the power to handle a "pending" state where you've made a request for dat ...

  3. dfsdf

    This project was bootstrapped with Create React App. Below you will find some information on how to ...

  4. puppeteer(五)chrome启动参数列表API

    List of Chromium Command Line Switches https://peter.sh/experiments/chromium-command-line-switches/ ...

  5. CEF 支持的命令行参数

    参考:https://peter.sh/experiments/chromium-command-line-switches/ List of Chromium Command Line Switch ...

  6. SpringKafka生产端配置类ProducerConfig.java源码

    /** * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreeme ...

  7. Capabilities & ChromeOptions

    https://sites.google.com/a/chromium.org/chromedriver/capabilities http://stackoverflow.com/questions ...

  8. List of Chromium Command Line Switches(命令行开关集)——官方指定命令行更新网址

    转自:http://peter.sh/experiments/chromium-command-line-switches/ There are lots of command lines which ...

  9. OBD Problem Vehicles

    This page contains a list of vehicles that are known to be non-compliant with OBD-II in one way or a ...

随机推荐

  1. scrollWidth到底是什么???

    贴上MDN对scrollwidth的定义: The Element.scrollWidth read-only property is a measurement of the width of an ...

  2. mysql源码安装(包括5.5和5.7)

    1.mysql5.5源码安装 yum install -y cmake ncurses-devel ncurses cd /usr/src wget -c https://cdn.mysql.com/ ...

  3. pwd---以绝对路径的方式显示用户当前工作目录

    pwd命令以绝对路径的方式显示用户当前工作目录.命令将当前目录的全路径名称(从根目录)写入标准输出.全部目录使用/分隔.第一个/表示根目录,最后一个目录是当前目录.执行pwd命令可立刻得知您目前所在的 ...

  4. JQ遍历 input 并修改name属性

    1.执行完克隆行后,会出现name属相相同的问题 function addRow(){ var obj = $("tr[name='info']:last"); var objCl ...

  5. 利用"SQL"语句自动生成序号的两种方式

    1.首先,我们来介绍第一种方式: ◆查询的SQL语句如下: select row_number() over (order by name) as rowid, sysobjects.[name] f ...

  6. Codeforces 474D Flowers (线性dp 找规律)

    D. Flowers time limit per test:1.5 seconds memory limit per test:256 megabytes We saw the little gam ...

  7. VC、IE、ASP环境下打印、预备的完美解决方式

    一种基于XML的报表开发工具,它支持从设计报表.调用API打印.预览,能支持分布式报表.方便报表的存储.转发. 在报表中能嵌入VBScript,能方便地訪问VB,VC的变量,能訪问COM组件.ADO等 ...

  8. 手动连接数据库(jdbc)

    import java.sql.Connection; import java.sql.DriverManager; import java.sql.PreparedStatement; import ...

  9. js---11闭包

    //匿名立即调用函数 (function(){//把a,b,f全部隐藏在函数中,外部访问不到, var a = 5; var b = 6; function f(){ alert(a); } wind ...

  10. uva 11248 最小割

    Dinic 1 #include<iostream> #include<string> #include<algorithm> #include<cstdli ...