Skip to content

Instantly share code, notes, and snippets.

@mmcc
Last active June 28, 2019 22:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mmcc/eca3c9d906264ce1aa77472f7d29dd47 to your computer and use it in GitHub Desktop.
Save mmcc/eca3c9d906264ce1aa77472f7d29dd47 to your computer and use it in GitHub Desktop.
Redux Confirmation Modal Examples
function *deleteAsset (action: Action<'AssetDeleteRequested'>) {
const { payload: { id }, meta: { callbackAction } } = action;
yield put({ type: 'ConfirmAction', payload: { actionType: action.type } });
const { canceled } = yield race({
confirmed: take('ActionConfirmed'),
canceled: take('ActionCanceled'),
});
if (canceled) {
yield cancel();
}
try {
yield call(Api.Assets.del, id);
yield put({
type: 'AssetDeleted',
payload: { id },
});
yield put(callbackAction);
} catch (error) {
yield put({ type: 'AssetDeleteFailed' });
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment