草庐IT

redux-observable

全部标签

javascript - RxJS,Observable,如何保存值并将映射切换到另一个

//ticker$willupdateevery3s//showHand$willonlytrigerafteruserclickbutton//IwouldliketotakelasttickerpriceasuserorderpricewhenuserclickbuttonletlastPrice:number;this.ticker$//WhatIamdoingnowispreservevaluetovairablehere..do(ticker=>lastPrice=ticker.closePrice).switchMap(()=>this.showHand$).subscri

javascript - document.observe ('dom:loaded' , 函数 () {

有没有办法让这个原型(prototype)js只在dom发生变化而没有加载时触发? 最佳答案 你可以观察到元素是这样变化的$('element').observe('change',function(e){});这是为表单元素保留的-textarea、select和input。最终代码看起来像这样:document.observe('dom:loaded',function(){$('element').observe('change',function(e){//dosomethinghere});});

javascript - 与 react/redux 共享 actions 和 reducers

我仍然是一个react/redux菜鸟。在一页上,我有大量的文本输入。一段时间后,我开始注意到我的操作文件具有做同样事情但输入不同的函数:exportfunctionsetInputName(string){return{type:'SET_CURRENT_NAME',payload:{value:string}};}exportfunctionsetInputCity(string){return{type:'SET_CURRENT_CITY',payload:{value:string}};}我的reducer看起来像:exportfunctioncurrentName(state

javascript - 在 Redux Reducer 达到状态之前格式化日期

我如何从标准JS日期对象格式化日期,该对象来自服务器并通过RESTapi通过Redux馈送到React,其初始输出为:"2016-05-16T13:07:00.000Z"转换成不同的格式?所以它被列为DDMMYYYY?我可以通过操作请求结果或负载在Action的Reducer中执行此操作吗:import{FETCH_BOOKS,FETCH_BOOK}from'../actions';constINITIAL_STATE={books:[],book:null};exportdefaultfunction(state=INITIAL_STATE,action){switch(action

javascript - 如何禁用 redux-form 中的字段?

我只是想禁用redux-form中的一个字段,如下所示,但它似乎没有任何效果。这是redux-form版本7.4.2。还有请帮忙 最佳答案 你可以传递Prop对象:props:object[optional]:ObjectwithcustompropstopassthroughtheFieldcomponentintoacomponentprovidedtocomponentprop.ThispropswillbemergedtopropsprovidedbyFielditself.//outsideyourrender()meth

javascript - 使用 flowtype 和 flow-typed 输入 redux store

我正在尝试totypethereduxstore像这样:consts:Store=createStore(todoApp)但我明白了identifierStore...Couldnotresolvename流量错误知道如何解决这个问题吗?我正在使用这个流类型的声明://flow-typedsignature:ba132c96664f1a05288f3eb2272a3c35//flow-typedversion:c4bbd91cfc/redux_v3.x.x/flow_>=v0.33.xdeclaremodule'redux'{/*S=StateA=Action*/declaretype

javascript - 将 observables 数组传递给 zip

我有一个observable数组,想传递给Rx.Observable.zip。我试过了,但根本没有订阅。代码片段(仅作为示例):constsourceOne=Rx.Observable.of('Hello');constsourceTwo=Rx.Observable.of('World!');constsourceThree=Rx.Observable.of('Goodbye');constsourceFour=Rx.Observable.of('World!');constarr$=[sourceOne,sourceTwo,sourceThree,sourceFour];constz

javascript - Redux 展示组件与容器组件

我是使用redux进行React开发的初学者。我想知道什么是展示组件和容器组件。如何将组件分类为Presentational或Container?这两者有什么区别?以这种方式对组件进行分类有什么好处? 最佳答案 如果将组件分为两类,您会发现组件更易于重用和推理。我称它们为容器和展示组件。我假设你了解redux架构容器组件了解redux订阅redux状态分发到reduxAction由react-redux生成关注事物的运作方式演示组件不知道redux从Prop中读取数据调用props的回调由开发者编写关注事物的外观对组件进行分类的好处

javascript - Redux 如何将状态传递给 mapStateToProps?

我试图了解React和Redux是如何工作的,我正在查看来自thisexampleproject的FuelSavingsPage.js.我在mapDispatchToProps中得到了actions的来源,但我不明白state是如何传递给mapStateToProps或者dispatch如何传递给mapDispatchToProps。这是怎么回事?importReact,{PropTypes}from'react';import{connect}from'react-redux';import{bindActionCreators}from'redux';import*asaction

javascript - Intersection Observer API 触发回调,即使元素不在 View 中

我正在尝试查找元素何时出现在屏幕上(尝试实现无限加载器)。为列表中的最后一项绑定(bind)观察者并收听,不幸的是在chrome62mac10.10中,即使我正在观察的元素不在视口(viewport)中,回调也会触发。当我检查相交率时,我可以很容易地阻止它。这是IntersectionObserver的工作方式吗?在此先感谢您的帮助。bindIO();functionioCallback(entries,observer){console.log("entries");console.log(entries);entries.forEach(entry=>{//Eachentrydes