2.1.0 • Published 5 years ago

redux-routines-ts v2.1.0

Weekly downloads
4
License
MIT
Repository
github
Last release
5 years ago

Redux-Routines-Ts

A helper for the REQUEST/SUCCESS/FAILURE action creator pattern found in Redux.

Utilizes deox to provide strong TypeScript inferences.

Helps reduce boilerplate when making asynchronous API calls in Sagas or Thunks.

API Reference

Full Example


Example Usage

// saga.ts
function* fetchFooSaga({ meta }: ReturnType<typeof fetchFoo.trigger>) {
  const { id } = meta;

  try {
    const foo = yield call(api, id);
    yield put(fetchFoo.success(foo, meta));
  } catch (error) {
    yield put(fetchFoo.failure(error, meta));
  }
}

export function* fooSaga() {
  yield takeEvery(fetchFoo.TRIGGER, fetchFooSaga);
}

// Component.tsx
dispatch(fetchFoo.trigger({ id: '5' }))

Inspired By

2.1.0

5 years ago

2.0.0

5 years ago

1.0.0

5 years ago