@mynewsdesk/promise-saga
v1.1.2
Published
saga util to handle promise as actions
Downloads
3
Maintainers
Keywords
Readme
PromiseSaga
Util function to return promise results as redux actions
Releasing
- use
lerna publish
in the parent folder
Testing
- to run the tests use:
yarn test
- to rerun test when saving run:
yarn test --watch
- coverage reports can be shown with:
yarn coverage
Documentation
import { take, actionChannel } from 'redux-saga/effects';
import createPromiseSaga from '@mynewsdesk/promise-saga';
function* watchFetchUrl() {
const channel = yield actionChannel('FETCH_URL');
while (true) {
const action = yield take(channel);
const { url } = action.payload;
yield* createPromiseSaga(
action,
fetch,
url
)();
}
}
export default function* sagas() {
yield [
watchFetchUrl(),
];
}