gpt4 book ai didi

redux-observable - redux-observable中ActionsObservable的作用是什么

转载 作者:行者123 更新时间:2023-12-01 00:19:56 25 4
gpt4 key购买 nike

我不太明白 ActionsObservable 的目的是什么.文档中没有任何关于它的内容,但我看到它在这里和那里被使用 in examples .

为什么不直接使用:

import { of } from 'rxjs/observable/of';

或者
import { from } from 'rxjs/observable/from';

?

最佳答案

一旦我开始编写测试,我遇到了一个史诗般的情况:
action$.ofType(CREATE_PAYMENT_METHOD))
并且因为“常规” Observable 没有 ofType在原型(prototype)链中,当我对 Action 进行 stub 时,它抛出了一个错误:

const action$ = of({
type: types.CREATE_PAYMENT,
});

const response = await epics.createPayment(action$, store, fetch)
.pipe(toArray()).toPromise();

action$.ofType is not a function



当我使用它时它起作用了:
const action$ = ActionsObservable.of({
type: types.CREATE_PAYMENT,
});

关于redux-observable - redux-observable中ActionsObservable的作用是什么,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49478469/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com