Last active
June 28, 2019 22:48
-
-
Save mmcc/eca3c9d906264ce1aa77472f7d29dd47 to your computer and use it in GitHub Desktop.
Redux Confirmation Modal Examples
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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