Skip to content

Instantly share code, notes, and snippets.

@radzserg
Last active July 15, 2019 18:14
Show Gist options
  • Select an option

  • Save radzserg/58cb3d9274b65a02c77ce6ee8e907b51 to your computer and use it in GitHub Desktop.

Select an option

Save radzserg/58cb3d9274b65a02c77ce6ee8e907b51 to your computer and use it in GitHub Desktop.
export default function* configureSagas() {
yield all([
watchLoadProducts(),
watchSaveProduct(),
// all the watchers that we need from all
// parts of our app
]);
}
// and a specfic saga will look like
import backendApi from "./path/to/backendApi";
import history form "./configureHistory";
export function* watchSaveProduct() {
yield takeEvery(SAVE_PRODUCT, saveProduct);
}
export function* saveProduct(
action: ISaveProductAction
) {
const userDetails = backendApi.saveProduct(action.productId, action.productData);
yield put(saveUserDetails(userDetails));
history.push("/products");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment