redux-saga

A 'yield' expression is only allowed in a generator body

戏子无情 提交于 2021-02-11 13:47:42
问题 I'm using redux-saga to fetch server api data. My question is that I'm trying to design following code. However yield put(get01Action(members)); which is commented out has following Syntax error. A 'yield' expression is only allowed in a generator body. I don't know how to manage it. import '@babel/polyfill'; import { fork, take, put } from 'redux-saga/effects'; import axios from "axios"; export function* rootSaga(){ yield fork(fetch01); yield fork(fetch02); } function* fetch01() { while

How to cancel all running sagas when navigating between page views

我与影子孤独终老i 提交于 2021-02-10 05:37:15
问题 I'm trying to find a simple and easy way to cancel all running sagas within a "page" when the user decides to navigate to another "page" within the app... We are not using routing, but instead each "page" is its own widget within a larger host application that is responsible for creating and loading each page when the user navigates... Currently, we are using redux-saga and have setup logic like so (simplified for brevity) when a page widget is created and loaded... // page-sagas export

Handling Redux Saga result in view from which action call originates

微笑、不失礼 提交于 2021-02-09 10:57:33
问题 I'm new to Redux Saga, coming from Redux Thunk. In some situations, I need to know whether an API call fails or succeeds from inside the view from which I called the action. With Redux Thunk, I would do something like the following. My component and action creator would look like this: class MyComponent extends Component { componentDidMount() { this.props.actions.fetchItems() .then(result => { if (result.status === 'OK') { console.log('Request succeeded, take particular action in this view')

Handling Redux Saga result in view from which action call originates

喜你入骨 提交于 2021-02-09 10:57:15
问题 I'm new to Redux Saga, coming from Redux Thunk. In some situations, I need to know whether an API call fails or succeeds from inside the view from which I called the action. With Redux Thunk, I would do something like the following. My component and action creator would look like this: class MyComponent extends Component { componentDidMount() { this.props.actions.fetchItems() .then(result => { if (result.status === 'OK') { console.log('Request succeeded, take particular action in this view')

Firebase getIdToken returns object

血红的双手。 提交于 2021-02-07 08:19:29
问题 I am using redux-saga and redux-saga-firebase library to integrate firebase with redux-sagas. The problem is when I sign in a user, for example with signInWithEmailAndPassword and even connect channel to get the signed user and track user changes, I am not able to get correct token. getIdToken , getIdTokenResult methods just return objects with the following representation: { a: 0 b: qb {a: null, g: ƒ, b: ƒ, f: undefined, next: null, …} c: A {a: 0, i: undefined, c: A, b: qb, f: qb, …} f: qb

Firebase getIdToken returns object

别说谁变了你拦得住时间么 提交于 2021-02-07 08:17:28
问题 I am using redux-saga and redux-saga-firebase library to integrate firebase with redux-sagas. The problem is when I sign in a user, for example with signInWithEmailAndPassword and even connect channel to get the signed user and track user changes, I am not able to get correct token. getIdToken , getIdTokenResult methods just return objects with the following representation: { a: 0 b: qb {a: null, g: ƒ, b: ƒ, f: undefined, next: null, …} c: A {a: 0, i: undefined, c: A, b: qb, f: qb, …} f: qb

How to execute multiple generators based on actions dispatched asynchronously

99封情书 提交于 2021-01-29 08:42:28
问题 I am trying to dispatch multiple actions which will trigger multiple generator functions. OnClick dispatch({ type: "ACTION_1", data1}); dispatch({ type: "ACTION_2", data2}); saga.js function* method1(action){ //... const response = yield call(api, requestParams); //... } function* method2(action){ //... const response1 = yield call(api, requestParams1); //... //dependent on response1 const response2 = yield call(api, requestParams2); //... //dependent on response2 const response3 = yield call

Adding properties to created Redux Store in Typescript

笑着哭i 提交于 2021-01-29 06:24:27
问题 I'm having issues adding a property when I create a new Redux Store in Typescript: const bindMiddleware = middleware => { if (process.env.NODE_ENV !== 'production') { const { composeWithDevTools } = require('redux-devtools-extension') return composeWithDevTools(applyMiddleware(...middleware)) } return applyMiddleware(...middleware) } function configureStore (initialState = exampleInitialState) { const sagaMiddleware = createSagaMiddleware() const store = createStore( rootReducer, initialState

redux-saga: eventChannel and listener which react callback return

守給你的承諾、 提交于 2021-01-28 15:31:12
问题 In react-native backhandler listener react to callback function and act appropriately. I need to read my store and depending on it, return true or false. But I cant use select effect in normal function and I cant affect listener callback function from "watchBackButton" function. export function* backButtonListen() { return eventChannel(emitter => { const backHandlerListener = BackHandler.addEventListener( "hardwareBackPress", () => { emitter("back pressed"); } ); return () => {

Why can't I use nested yield in for..in loop in Redux-Saga

♀尐吖头ヾ 提交于 2021-01-28 05:13:28
问题 So I have tasks object with ids and values. With for in loop I want to read 'members' property. If it exist, and first element of array !=='all' I want to make request to firebase for read document by given id. But I cant use yield , there is error: Failed to compile. ./src/containers/modules/Tasks/store/sagas/tasksSagas.js Line 27: Parsing error: Unexpected reserved word 'yield' Why am I getting it? I can't use nested yields? //Fetching users for tasks for (const task in tasks) { if (tasks