redux-saga

What are selectors in redux?

烂漫一生 提交于 2019-11-28 17:22:27
问题 I am trying to follow this code in redux-saga export const getUser = (state, login) => state.entities.users[login] export const getRepo = (state, fullName) => state.entities.repos[fullName] Which is then used in the saga like this: import { getUser } from '../reducers/selectors' // load user unless it is cached function* loadUser(login, requiredFields) { const user = yield select(getUser, login) if (!user || requiredFields.some(key => !user.hasOwnProperty(key))) { yield call(fetchUser, login)

Why use Redux-Observable over Redux-Saga?

本秂侑毒 提交于 2019-11-28 13:20:34
问题 I have used Redux-Saga. Code written with it is easy to reason so far, except JS generator function is messing up my head from time to time. From my understanding, Redux-Observable can achieve the similar job that handles side effects but without using generator function. However, docs from Redux-Observable does not provide many opinions of why it is superior against Redux-Saga. I would want to know whether not using generator function is the only benefit of using Redux-Observable. And what

Use async react-select with redux-saga

岁酱吖の 提交于 2019-11-27 16:22:48
问题 I try to implement a async react-select (Select.Async). The problem is, we want to do the fetch in redux-saga. So if a user types something, the fetch-action should be triggered. Saga then fetches the record and saved them to the store. This works so far. Unfortunately loadOptions has to return a promise or the callback should be called. Since the newly retrieved options get propagated with a changing property, I see no way to use Select.Async together with saga to do the async fetch call.

Pros/cons of using redux-saga with ES6 generators vs redux-thunk with ES2017 async/await

亡梦爱人 提交于 2019-11-27 02:19:54
There is a lot of talk about the latest kid in redux town right now, redux-saga/redux-saga . It uses generator functions for listening to/dispatching actions. Before I wrap my head around it, I would like to know the pros/cons of using redux-saga instead of the approach below where I'm using redux-thunk with async/await. A component might look like this, dispatch actions like usual. import { login } from 'redux/auth'; class LoginForm extends Component { onClick(e) { e.preventDefault(); const { user, pass } = this.refs; this.props.dispatch(login(user.value, pass.value)); } render() { return (

Pros/cons of using redux-saga with ES6 generators vs redux-thunk with ES2017 async/await

我与影子孤独终老i 提交于 2019-11-26 10:04:08
问题 There is a lot of talk about the latest kid in redux town right now, redux-saga/redux-saga. It uses generator functions for listening to/dispatching actions. Before I wrap my head around it, I would like to know the pros/cons of using redux-saga instead of the approach below where I\'m using redux-thunk with async/await. A component might look like this, dispatch actions like usual. import { login } from \'redux/auth\'; class LoginForm extends Component { onClick(e) { e.preventDefault();