标签: flux

登录ajax请求Flux React?

如何 使用 提供响应的flux结构ajax请求
登录表单提交(React Component)后怎么办? 你能提供一些例子吗?


flux reactjs reactjs-flux

3
推荐指数
1
解决办法
4208
查看次数

我应该在componentWillReceiveProps中调用操作吗?

我的直觉告诉我没有,但我很难想到一个更好的方法.

目前,我有一个显示项目列表的组件.根据提供的内容props,此列表可能会更改(即过滤更改或上下文更改)

例如,给定一个新的this.props.type,状态将更新如下:

componentWillReceiveProps(nextProps) {
        if (nextProps.type == this.state.filters.type) return

        this.setState({
            filters: {
                ...this.state.filters,
                type: nextProps.type,
            },
            items: ItemsStore.getItems().filter(item => item.type == nextProps.type)
        })
}
Run Code Online (Sandbox Code Playgroud)

这一切都很好,但现在我的要求已经改变,我需要添加一个新的过滤器.对于新过滤器,我必须执行API调用以返回有效项ID的列表,并且我只想在同一列表组件中显示具有这些id的项.我该怎么办呢?

我曾考虑过从中调出适当的动作componentWillReceiveProps,但这似乎不对.

componentWillReceiveProps(nextProps) {
        if (nextProps.type == this.state.filters.type && nextProps.otherFilter == this.state.filters.otherFilter) return

        if (nextProps.otherFilter != this.state.filters.otherFilter) {
            ItemsActions.getValidIdsForOtherFilter(nextProps.otherFilter)
            // items will be properly updated in store change listener, onStoreChange below
        }

        this.setState({
            filters: {
                ...this.state.filters,
                type: nextProps.type,
                otherFilter: nextProps.otherFilter,
            },
            items: ItemsStore.getItems().filter(item => item.type == nextProps.type)
        })
}, …
Run Code Online (Sandbox Code Playgroud)

flux reactjs

3
推荐指数
1
解决办法
3812
查看次数

从插件配置中删除默认的pi flexform字段 - typo3

我创建了一个typo3扩展.我有一个flex表单来配置我的插件.表单包含一些默认的typo3配置,如插件模式,存储文件夹和递归.我想隐藏这些字段.怎么可能?

在此输入图像描述

typo3 flux extbase

3
推荐指数
1
解决办法
493
查看次数

Redux - 每次使用新变量在减速器 switch 语句中定义新状态?

我的减速机看起来像这样:

switch (action.type) {
      case "UPDATE_CURRENT_USER":
        let newState = {...state, ...action.payload };
        return newState;
      case "GET_CURRENT_USER":
        return state;
      case "UPDATE_USERNAME":
        newState = {...state, name: action.payload.name};
        return state;
  }
Run Code Online (Sandbox Code Playgroud)

现在,我第二次使用时newState不再定义它。我只是使用上面定义的变量。这个可以吗?我想重新定义它,但出现错误。但我不确定这种方式是否仍然会给我正确的结果 - 尽管一切似乎都工作正常?

flux reactjs redux react-redux

3
推荐指数
1
解决办法
2397
查看次数

从 Mono 的列表中创建 Flux 的正确方法

假设我有一个使用 CustomObjects 列表的 API 操作。对于这些对象中的每一个,它都会调用一个创建 Mono 的服务方法。如何以惯用的非阻塞方式从这些 Mono 对象创建 Flux?

我现在想到的是这个。我更改了方法名称以更好地反映其预期目的。

fun myApiMethod(@RequestBody customObjs: List<CustomObject>): Flux<CustomObject> {

    return Flux.create { sink ->
        customObjs.forEach {

            service.persistAndReturnMonoOfCustomObject(it).map {
                sink.next(it)
            }
        }
        sink.complete()
    }
}
Run Code Online (Sandbox Code Playgroud)

此外,我是否需要订阅流量才能真正返回一些东西?

mono spring flux kotlin project-reactor

3
推荐指数
1
解决办法
6391
查看次数

Vuex反应式mapGetters与传递的参数

我有很多将参数传递给商店的吸气剂,例如:

this.$store.getters['getSomeThing'](this.id)
Run Code Online (Sandbox Code Playgroud)

我没有找到关于如何mapGetters在传递参数的同时如何最佳地使用来保持反应性的建议。我发现的一个建议是映射吸气剂,然后将参数传递给mount:

computed: {  
  ...mapGetters([
    'getSomeThing'
  ])
},
mounted () {
  this.getSomeThing(this.id)
}
Run Code Online (Sandbox Code Playgroud)

这实际上似乎不是最佳选择,因为它只会检查已挂载状态的更改。关于如何在将参数传递给吸气剂时如何最好地保持反应性的任何建议?这是与上述代码匹配的吸气剂的示例:

getSomeThing: (state) => (id) => {
  return state.things.find(t => { return t.id === id })
}
Run Code Online (Sandbox Code Playgroud)

state flux vue.js vuex vuejs2

3
推荐指数
1
解决办法
1068
查看次数

如何有选择地跳过 Flux 上的多个处理步骤

我有从套接字接收的动态热数据流。我需要检查条件,如果值匹配,则跳转到步骤 3 并显示新消息。

    final Flux<Msg> msgs = Flux.generate(receiver);

    final Flux<Msg> processed = msgs
        .map(this::checkCondition)  //step1
        .map(remote::doLongRunning) //optional step2
        .map(this::processFurther)  //step3
 ...

    public Msg checkCondition(Msg msg) {
        if(doCheck(msg)){
            //is there a way to jump to step3 here ?
            return new OtherMsg(msg, "someAdditionalData")) 
        } else{
            return msg
        }
    }

Run Code Online (Sandbox Code Playgroud)

我能想到的唯一选择 - 是将 Flux 分开并将其组装回来,有没有更干净的方法?

   final Flux<Msg> msgs = Flux.generate(receiver);

        final Flux<OtherMsg> checked = msgs
            .filter(this::doCheck) //step1
            .map(msg -> new OtherMsg(msg, "someAdditionalData"));

        final Flux<OtherMsg> unchecked = msgs
            .filter(msg -> !doCheck(msg)) //step1
            .map(remote::doLongRunning);  //optional …
Run Code Online (Sandbox Code Playgroud)

java flux project-reactor option-type

3
推荐指数
1
解决办法
2457
查看次数

Spring Reactor onErrorContinue 不起作用

根据文档,我期望onErrorContinue将忽略错误元素并继续序列。以下测试用例因异常而失败

java.lang.AssertionError: expectation "expectNext(12)" failed (expected: onNext(12); actual: onError(java.lang.RuntimeException:
Run Code Online (Sandbox Code Playgroud)
    @Test
            public void testOnErrorContinue() throws InterruptedException {

                Flux<Integer> fluxFromJust = Flux.just(1, 2,3,4,5)
                        .concatWith(Flux.error(new RuntimeException("Test")))
                        .concatWith(Flux.just(6))
                        .map(i->i*2)
                        .onErrorContinue((e,i)->{
                            System.out.println("Error For Item +" + i );
                        })
                        ;
                StepVerifier
                        .create(fluxFromJust)
                        .expectNext(2, 4,6,8,10)
                        .expectNext(12)
                        .verifyComplete();
        }
Run Code Online (Sandbox Code Playgroud)

flux project-reactor spring-webflux

3
推荐指数
1
解决办法
6520
查看次数

如何在 Flux&lt;String&gt; 上执行 flatMap() 时获取索引号

我有一个代码块如下

var x = Flux.just("A", "B", "C", "D");
        x.flatMap(y -> {
            System.out.println(y);
            return Mono.just(y);
        }).subscribe();
Run Code Online (Sandbox Code Playgroud)

成功打印:

A
B
C
D
Run Code Online (Sandbox Code Playgroud)

除了字符串值之外,有没有办法可以打印索引/记录号?

A - 1
B - 2
C - 3
D - 4
Run Code Online (Sandbox Code Playgroud)

flux spring-boot reactive spring-webflux

3
推荐指数
1
解决办法
2387
查看次数

如何在Grafana的变量过滤器上选择多个变量?

我配置了一个名为“product”的变量,其中包含以下值:

prod1,prod2,prod3,prod4
Run Code Online (Sandbox Code Playgroud)

我已经选择了多值选项,如下图所示:

多值选择变量

influxdb 中的测量是这样的:

col1    col2    col3
A       prod1   10
B       prod2   20
C       prod3   30
D       prod1   40
E       prod4   50
Run Code Online (Sandbox Code Playgroud)

所以我没有将 col2 设置为 的行prod1+prod2。当我尝试在仪表板变量上选择prod1和时,我得到prod2No Data

是否有不同的方法来配置仪表板的变量,以便我可以正确选择多值?或者我是否必须在 Influxdb 测量中创建 rows prod1+prod2, ?prod2+prod3

flux influxdb grafana grafana-variable

3
推荐指数
1
解决办法
2万
查看次数