我有一个带有像这样的通量存储的多步骤反应形式:
// MultiForm.js
....
import LoadFile from './components/LoadFile';
import LoadPeople from './components/LoadPeople';
import Confirmation from './components/Confirmation';
class MultiForm extends Component {
.
.
.
nextPage() {
// Update page number with a flux action
MultiStepActions.nextPage();
}
previousPage() {
// Update page number with a flux action
MultiStepActions.previousPage();
}
render() {
const {pagina} = this.state;
<div className="container">
{page === 1 && <LoadFile
handleChange={this.handleChange}
file={this.state.file}
nextPage={this.nextPage}
data1={this.state.data1}
data2={this.state.data2}
data3={this.state.data3}/>
}
{page === 2 && <LoadPeople
listPeople={this.state.listPeople}
nextPage={this.nextPage}
previousPage={this.previousPage}
handleChangePeople={this.handleChangePeople}/>
}
{page === …Run Code Online (Sandbox Code Playgroud) componentWillMount()每次切换路线时,我都是我的人。
还有其他方法可以处理商店状态的变化吗?
当我第一次使用这两个功能时还可以,但是,当我切换路线并返回并再次尝试使用它们时,我收到此消息
warning.js:45 Warning: setState(...): Can only update a mounted or mounting component. This usually means you called setState() on an unmounted component. This is a no-op. Please check the code for the undefined component.
库存清单.js
import React from "react";
import InventoryItem from "../components/InventoryItem";
import InventoryItemStore from "../stores/InventoryItemStore";
import { Link } from "react-router";
export default class InventoryList extends React.Component {
constructor() {
super();
this.state = {
items: InventoryItemStore.getAll(),
}
}
componentWillMount() {
InventoryItemStore.on("change", () => {
this.setState({ …Run Code Online (Sandbox Code Playgroud) 当我派遣行动时,我对行为有点困惑redux。
例子:
onPressAdd() {
this.props.addFloor({
name: this.state.floor_name,
});
console.log(this.props.floors);
}
Run Code Online (Sandbox Code Playgroud)
我正在调用 redux 操作addFloor,将地板添加到存储中的数组中,然后我 console.log 这个变量,并且我期望更新状态([{name:'whatever'}]),但我得到[](空数组)
示例2:
async onPressAdd() {
await this.props.addFloor({
name: this.state.floor_name,
});
console.log(this.props.floors);
}
Run Code Online (Sandbox Code Playgroud)
在这个例子中,我得到了完美的更新商店:[{name:'whatever'}]
我到处都读到“如果没有 thunk 或 saga,Redux 操作调度是同步的(直接方式:调度操作->reduce->store”,但 rhis 证明调度是异步的。
那么真理在哪里呢?
给出 Influxdb 的 Flux 语言的以下查询:
from(bucket: "some-great-metrics")
|> range(start: v.timeRangeStart, stop: v.timeRangeStop)
|> aggregateWindow(every: 1mo, fn: sum)
|> yield()
Run Code Online (Sandbox Code Playgroud)
假设我当前的时区是PST. 如何确保尊重该特定时区 ( ) 中持续时间aggregateWindow的开始和结束?1moPST
到目前为止,在文档中搜索并没有给我带来太多启发。
在最近的反应器版本中,WorkQueueProcessor已被弃用,并在 3.5 版本中被删除。对于新的 Sinks 规范,我想知道 WorkQueueProcessor 是否有替代方案?我希望以循环方式将信号仅分发给其中一个订阅者。
我正在努力处理 Flux 中的 Influx 2 查询,了解如何将两个不同集(表)中的数据连接和映射到特定的所需输出。
我当前的 Flux 查询是这样的:
data = from(bucket: "foo")
|> range(start:-1d)
|> filter(fn: (r) => r._measurement == "io")
|> filter(fn: (r) => r["device_id"] == "12345")
|> filter(fn: (r) => r._field == "status_id" )
# count the total points
totals = data
|> count(column: "_value")
|> toFloat()
|> set(key: "_field", value: "total_count")
# calculate the amount of onlines points (e.g. status = '1')
onlines = data
|> filter(fn: (r) => r._value == 1)
|> count(column: …Run Code Online (Sandbox Code Playgroud) 我有一个代码,我可以在循环中执行一段逻辑,并使用 Flux 之间有一些延迟。像这样的事情,
Flux.defer(() -> service.doSomething())
.repeatWhen(v -> Flux.interval(Duration.ofSeconds(10)))
.map(data -> mapper(data)) //map data
.takeUntil(v -> shouldContinue(v)) //checks if the loop can be terminated
.onErrorStop();
Run Code Online (Sandbox Code Playgroud)
现在,我想要增量延迟。这意味着,在前 5 分钟内,每次执行之间的延迟可能为 10 秒。然后,在接下来的 10 分钟内,延迟可以是 30 秒。并且,此后每次执行之间的延迟可以是一分钟。
我如何使用 Flux 来实现这一目标?
提前致谢。
因此,我一直在摆弄:最近使用了一些同构的React + Flux,并且发现一些概念实在令人困惑。我一直在研究有关如何构造同构应用程序的最佳实践,并正在寻求建议。
假设您正在创建一个由相同的REST API支持的Web应用程序和一个移动应用程序。您是否将REST API与网络应用程序捆绑在一起?我见过有人提倡捆绑和为REST API建立单独的代码库。
任何建议或建议的阅读表示赞赏!
我目前正在VueJS(尤其是Vuex)中编码应用程序。但是,我的问题与该库的联系并不紧密,而是与flux / redux / Vuex这样的商店拥有的体系结构紧密相关。
简单来说,我有几个API(每个团队一个API /数据库),每个团队/ API有几个用户,这些团队和用户由简单的对象表示,每个都有自己的子对象。重要说明:团队的成员当然是唯一的,但是团队的用户对于他们自己的团队而言是唯一的。用户的唯一性约束将为“ teamSlug / userSlug”。考虑到大量用户,我不能简单地加载所有团队的所有用户。
我的问题是如何正确构造我的应用程序/存储,以恢复给定用户数据块(与他的团队)的数据:如果我尚未加载此用户,请发出API请求以对其进行检索。当前,我已经创建了一个返回用户对象的吸气剂,该对象从用户和团队中获得了胜利。如果返回“ null”或带有“ .loading”到“ false”,我必须运行“ loadOne”动作,该动作将负责检索它:
import * as types from '../../mutation-types'
import users from '../../../api/users'
// initial state
const state = {
users: {}
}
// getters
const getters = {
getOne: state => (team, slug) => (state.users[team] || {})[slug] || null
}
// actions
const actions = {
loadOne ({ commit, state }, { team, slug }) {
commit(types.TEAM_USER_REQUEST, { team, slug })
users.getOne(team, slug)
.then(data => commit(types.TEAM_USER_SUCCESS, …Run Code Online (Sandbox Code Playgroud) flux ×10
reactjs ×4
redux ×3
influxdb ×2
javascript ×2
reactjs-flux ×2
vuex ×2
delay ×1
fluxible ×1
influxdb-2 ×1
java ×1
react-router ×1
reactor ×1
state ×1
timezone ×1
vuejs2 ×1