redux

catchError cancel all parallel requests

雨燕双飞 提交于 2020-03-04 17:37:13
问题 I made multiple requests in parallel. then I throw error when timeout. getAllDirections() { ... return from(urls).pipe( // a list of api urls mergeMap((urlParam, index) => this.http.get<ISchedules>(urlParam[0]).pipe( map(dataRes => { return dataRes; }), timeout(6000), catchError(error => { console.log(error); return throwError(`Request timeout ${error}`); }) ) ) ); Then in my effect I capture the error $LoadSchedulingsByDirectionsByBranch = createEffect(() => this.actions$.pipe( ofType<any>

Redux学习笔记-React-Redux 的用法

拈花ヽ惹草 提交于 2020-03-04 15:35:22
参考:https://segmentfault.com/a/1190000015042646 https://www.jianshu.com/p/e3cdce986ee2 https://segmentfault.com/a/1190000010416732?utm_source=tag-newest 介绍 React-Redux 是 Redux 的官方 React 绑定库。它能够使你的 React 组件从 Redux store 中读取数据,并且向 store 分发 actions 以更新数据。 react-redux仅有2个API,Provider和connect,Provider提供的是一个顶层容器的作用,实现store的上下文传递。 connect方法比较复杂,虽然代码只有368行,但是为redux中常用的功能实现了和react连接的建立。 API介绍 conncet([mapStateToProps], [mapDispatchToProps], [mergeProps], [options]) conncet连接React组件与 Redux store, 实现了redux中常用的功能和react连接的建立。 import {connect} from 'react-redux'; const mapState = (state) => ({ username:

react项目必备组件

帅比萌擦擦* 提交于 2020-03-03 11:50:53
redux Redux 是 JavaScript 状态容器,提供可预测化的状态管理。相当于vue的vuex,可以跨组件、跨页面推送数据。应用场景如:购物车、会员登录等功能模块。 Redux 由 Flux 演变而来,避开了 Flux 的复杂性。 不管你有没有使用过它们,只需几分钟就能上手 Redux。 Redux 的基本思想是整个应用的 state 保持在一个单一的 store 中。store 就是一个简单的 javascript 对象,而改变应用 state 的唯一方式是在应用中触发 actions,然后为这些 actions 编写 reducers 来修改 state。整个 state 转化是在 reducers 中完成,并且不应该有任何副作用。 安装: npm install redux --save npm install react-redux --save redux-thunk redux-thunk 则可以用来延迟 action 的派发(dispatch),这可以处理异步 action 的派发(dispatch)。 安装: npm install --save-dev redux-thunk umi-request 网络请求库,基于 fetch 封装, 兼具 fetch 与 axios 的特点, 旨在为开发者提供一个统一的api调用方式, 简化使用, 并提供诸如缓存,

react-virtualized table x-scrolling

有些话、适合烂在心里 提交于 2020-03-03 08:52:32
问题 Is it possible to set a x-scrolling in react-virtualized? I have a table with a fixed width, and more columns to display than I got space in my table, so I need a x-scrollinig. In my tests if i did it, the table just shrinked up and did just display '...''s for content if the table runs out of space. 回答1: Intro paragraph for react-virtualized Table docs (emphasis added): Table component with fixed headers and windowed rows for improved performance with large data sets. This component expects

The state of this element is Undefined for first time?

牧云@^-^@ 提交于 2020-03-03 07:48:46
问题 I am trying to create toggle switch in my application and i am new to redux. Posting this question after trying very hard and looking eveywhere online.Please help. My Reducer is below: const initialState = { preview: "off", cards: }; const cardReducer = (state = initialState, action) => { switch (action.type) { case "FIND_ALL_CARDS": return { cards: action.cards }; case "DELETE_CARD": return { cards: state.cards.filter(card => card.id !== action.cardId) }; case "CREATE_CARD": return { cards:

The state of this element is Undefined for first time?

生来就可爱ヽ(ⅴ<●) 提交于 2020-03-03 07:48:06
问题 I am trying to create toggle switch in my application and i am new to redux. Posting this question after trying very hard and looking eveywhere online.Please help. My Reducer is below: const initialState = { preview: "off", cards: }; const cardReducer = (state = initialState, action) => { switch (action.type) { case "FIND_ALL_CARDS": return { cards: action.cards }; case "DELETE_CARD": return { cards: state.cards.filter(card => card.id !== action.cardId) }; case "CREATE_CARD": return { cards:

手动实现简易版 react-redux

隐身守侯 提交于 2020-03-03 00:35:53
实现简易版 react-redux 上一节我们实现了简易版的 redux,本节主要实现 react-redux。 同时解决下面问题: 相比 redux, react-redux 有什么好处/做了什么 react-redux 用法 react-redux 有什么好处 redux中的 createStore 方法返回三个内置方法getState, dispatch, subscribe。 每次获取属性都需要 store.getState,更新需要 dispatch。 在组件中, 我们想将state和 dispatch方法映射到props上,这样取值就变得非常简单,而 react-redux 就实现了这一层。 react-redux 实现 如上图,通过 mapStateToProps方法将 state 转为可以传递的 props dispatch方法有两种形式,obj和function,通过不同的方法来实现将 dispatch方法转为 props 接下来,依次来实现这些方法 Provider // 创建context const ValueContext = React . createContext ( ) ; export class Provider extends Component { render ( ) { return ( < ValueContext .

前端开发框架React-Admin

假装没事ソ 提交于 2020-03-02 11:38:15
前言 React-Admin是基于React16.x、Ant Design3.x的管理系统架构。 采用前后端分离,内置了许多管理系统常用功能,通过一些脚本、封装帮助开发人员快速开发管理系统,集中精力处理业务逻辑。 背景 一般的互联网公司内部或者对外都会有大量的管理系统,传统公司一般有后端开发人员进行管理系统开发,所用技术大多都是jsp、模版语言等。 随着公司的发展,管理系统数量和复杂度不端增加,开发人员耗费大量的精力在开发和维护管理系统上。 由于管理系统大多是公司内部使用,很多公司、团队并不重视,导致可用性差、bug多、页面丑陋。使用者怨声载道,开发者苦不堪言。。。 技术迭代 随着前端的技术发展迭代,传统的基于后端模版语言、jQuery的开发方式已经过时,难以应对复杂的需求、快速的项目迭代。 近几年随着React、Es6等技术的兴起,让前端可以与后端分离、可以组件化模块化,拥有了构建大型复杂项目的能力。 困难 WebPack开发五分钟,配置两小时,各种解决方案要结合:React、组件库、Redux、Router、ajax、国际化、主题、Less、CSS Module。。。 社区上有很多好的工具、组件,但是整合起来形成系统的解决方案的寥寥无几。要自己做一个?基础代码才刚刚写的溜,还要加班改bug,哪儿有时间搞框架~ React-Admin介绍 React

随行付微服务前端开发框架React Admin

会有一股神秘感。 提交于 2020-03-02 11:03:52
前言 React-Admin是基于 React16.x 、 Ant Design3.x 的管理系统架构。 采用前后端分离,内置了许多管理系统常用功能,通过一些脚本、封装帮助开发人员快速开发管理系统,集中精力处理业务逻辑。 背景 一般的互联网公司内部或者对外都会有大量的管理系统,传统公司一般有后端开发人员进行管理系统开发,所用技术大多都是jsp、模版语言等。 随着公司的发展,管理系统数量和复杂度不端增加,开发人员耗费大量的精力在开发和维护管理系统上。 由于管理系统大多是公司内部使用,很多公司、团队并不重视,导致可用性差、bug多、页面丑陋。使用者怨声载道,开发者苦不堪言。。。 技术迭代 随着前端的技术发展迭代,传统的基于后端模版语言、jQuery的开发方式已经过时,难以应对复杂的需求、快速的项目迭代。 近几年随着React、Es6等技术的兴起,让前端可以与后端分离、可以组件化模块化,拥有了构建大型复杂项目的能力。 困难 WebPack开发五分钟,配置两小时,各种解决方案要结合:React、组件库、Redux、Router、ajax、国际化、主题、Less、CSS Module。。。 社区上有很多好的工具、组件,但是整合起来形成系统的解决方案的寥寥无几。要自己做一个?基础代码才刚刚写的溜,还要加班改bug,哪儿有时间搞框架~ React-Admin介绍 React

How to cancel execution of a previous action upon a new action?

淺唱寂寞╮ 提交于 2020-03-02 09:43:50
问题 I have an action creator which does an expensive calculation and dispatches an action every time the user inputs something (basically real time updating). However, if the user inputs multiple things, I don't want the prior expensive calculations to fully run. Ideally I want to be able to cancel execution of the previous calculations and just do the current one. 回答1: There's no built-in feature to cancel a Promise in an asynchronous action. You can try manually implement cancellation if you're