import { all, call, takeLatest } from "redux-saga/effects"; import PhotosActionTypes from "./photos.types"; export function* onRemoveAllPhotos() { yield takeLatest(PhotosActionTypes.REMOVE_ALL_PHOTOS, removeAllPhotosAction); } export function* removeAllPhotosAction() { try { //Physically delete all photosSagas. const fps = (yield FileSystem.readDirectoryAsync( FileSystem.documentDirectory + "photos" )).map((f) => { return FileSystem.documentDirectory + "photos/" + f; }); const all = []; fps.forEach((f) => all.push(FileSystem.deleteAsync(f))); yield Promise.all(all); console.log("All photos deleted."); } catch (error) { console.log("Saga Error: onRemoveAllPhotos", error); //yield put(signInFailure(error)); //logImEXEvent("redux_sign_in_failure", { user: email, error }); } } export function* photosSagas() { yield all([call(onRemoveAllPhotos)]); }