flux

Make Redux reducers and other non-components hot loadable

ⅰ亾dé卋堺 提交于 2019-12-04 08:34:23
问题 I'm having a tough time getting my reducers to be hot swapable. I'm using Webpack and react-transform-hmr . With this, all of the CSS and the components are hot loaded when I save, but when I try and work on another type of type - most notably the reducers - it would tell me to do a full refresh. I figured out that this is because I need to explicitly re-load the reducers in and accept the event. Which I'm doing with this code in my store.js : if(module.hot) { module.hot.accept('./reducers/',

Dubbo 3.0 !提升不止一点点!

蹲街弑〆低调 提交于 2019-12-04 08:27:13
Dubbo 自 2011 年 10 月 27 日开源后,已被许多非阿里系的公司使用,其中既有当当网、网易考拉等互联网公司,也不乏中国人寿、青岛海尔等大型传统企业。 自去年 12 月开始,Dubbo 3.0 便已正式进入开发阶段,并备受社区和广大 Dubbo 用户的关注。 本文将为您详细解读 Dubbo 3.0 预览版的新特性和新功能。 下面先解答一下两个有意思的与 Dubbo 相关的疑问: 1、为什么 Dubbo 一开源就是 2.0 版本?之前是否存在 1.0 版本? 笔者曾做过 Dubbo 协议的适配兼容,Dubbo 确实存在过 1.x 版本,而且从协议设计和模型设计上都与 2.0 的开源版本协议是完全不一样的。下图是关于 Dubbo 的发展路径: 2、阿里内部正在使用 Dubbo 开源版本吗? 是的,非常确定,当前开源版本的 Dubbo 在阿里巴巴被广泛使用,而阿里的电商核心部门是用的 HSF2.2 版本,这个版本是兼容了 Dubbo 使用方式和 Remoting 协议。当然,我们现在正在做 HSF2.2 的升级,直接依赖开源版本的 Dubbo 来做内核的统一。所以,Dubbo 是得到大规模线上系统验证的分布式服务框架,这一点毋容置疑。 Dubbo 3.0 预览版的要点 Dubbo 3.0 在设计和功能上的新增支持和改进,主要是以下四方面: 1、Dubbo 内核之 Filter

Changing components based on url with react router

北慕城南 提交于 2019-12-04 07:14:19
This is more of an architectural question regarding react than a specific issue, but what is considered best practice for managing state/props with a layout component and a several child components which are rendered based on the url? Note: I'm aware that similar questions have been asked, but this is a little bit different. [ How to update ReactJS component based on URL / path with React-Router Lets say I have something like the following code: A profile page (main layout view) with navigation links for profile sub-sections (settings, preferences, account details, etc), and a main panel where

How to handle one-to-many relationships in Flux stores

坚强是说给别人听的谎言 提交于 2019-12-04 00:10:54
I'm just starting to use flux (with redux for now) and am wondering how relationships are supposed to be handled. For an example we can use Trello that has boards with columns that contains cards. One approach would be to have one store/reducer for boards and have all the data in it there but that means some very fat stores since they would have to contain all the actions for columns and cards as well. Another approach i've seen is separating nested resources into for example BoardStore, ColumnStore and CardStore and use their ids as reference. Here's an example of where I am a bit confused:

Passing props from grandchildren to parent

狂风中的少年 提交于 2019-12-03 16:21:38
I have following React.js application structure: <App /> <BreadcrumbList> <BreadcrumbItem /> <BreadcrumbList/> <App /> The problem is, when I click on <BreadcrumbItem /> , I want to change a state in <App /> I used callback to pass props to <BreadcrumbList/> but that`s how far I got. Is there any pattaren how to easily pass props up to compenent tree ? How can I pass prop to <App /> , without doing any callback chaining ? If you are doing something simple then its often just better to pass the change in state up through the component hierarchy rather than create a store specifically for that

Flux: How to make an action wait for a store?

天大地大妈咪最大 提交于 2019-12-03 14:53:19
问题 I'm tying myself in knots with a React problem which I'm sure can't be as difficult as it seems to me right now. I'm building a single page app against a RESTful server API that returns resources, together with links that describe what can be done with that resource. And I'm trying to ensure that my client's ajax calls only use URLs retrieved from the server in this way. So, for example, my LoggedInSessionStore contains the URL that allows me to fetch the list of all public documents, say.

Getting router params into Vuex actions

谁都会走 提交于 2019-12-03 14:10:39
I would like to pass router params into Vuex actions, without having to fetch them for every single action in a large form like so: edit_sport_type({ rootState, state, commit }, event) { const sportName = rootState.route.params.sportName <------- const payload = {sportName, event} <------- commit(types.EDIT_SPORT_TYPE, payload) }, Or like so, edit_sport_type({ state, commit, getters }, event) { const payload = {sportName, getters.getSportName} <------- commit(types.EDIT_SPORT_TYPE, payload) }, Or even worse: grabbing params from component props and passing them to dispatch, for every dispatch.

React.js - flux vs global event bus

北战南征 提交于 2019-12-03 12:29:16
What is the advantage of using Flux over a global event bus? I think the dispatcher is all that is needed: component publishes 'user event' with data to the dispatcher dispatcher executes handler of the subscribed store handler publishes 'update event' with the store's updated properties dispatcher executes handler of the subscribed component, and updates component state with the store's updated properties What am I missing here that I can't do without Flux? I think what others have said about application structure and the change event is important, but I should add this one thing: The

How to handle nested api calls in flux

耗尽温柔 提交于 2019-12-03 11:23:13
I'm creating a simple CRUD app using Facebook's Flux Dispatcher to handle the creation and editing of posts for an English learning site. I currently am dealing with an api that looks like this: /posts/:post_id /posts/:post_id/sentences /sentences/:sentence_id/words /sentences/:sentence_id/grammars On the show and edit pages for the app, I'd like to be able to show all the information for a given post as well as all of it's sentences and the sentences' words and grammar details all on a single page. The issue I'm hitting is figuring out how to initiate all the async calls required to gather

Why should I keep the state flat

北战南征 提交于 2019-12-03 10:53:39
I'm using ReactJs with Redux and on some tutorials and codes I see people suggesting and using normalizr to keep the state flat . But what is the real advantage in keeping it flat ? Will I encounter any problems if I don't ? Is it necessary ? Three main reasons: Updating nested Javascript objects immutably generally results in uglier code that is harder to maintain, unless you use a utility library to wrap up the process Immutably updating nested data requires that you return new copies of all items in the nesting hierarchy. Since components generally do shallow-equality reference comparisons