1.0.9 • Published 4 years ago

redux-saga-service-wrapper v1.0.9

Weekly downloads
2
License
ISC
Repository
github
Last release
4 years ago

Redux-Saga Service Wrapper

Redux-Saga Service Wrapper is an approach that allows you to manage your services with only one Saga and call separate action accordingly, the rest is under your control! Perform anything you want.

Yes, you can use serviceWrapperSaga for your all service calls and manage your response for error and success cases. We use Map object for handling errors.

export const endpoints = {
  filter: () => `anyServicePath`
}
export const getService: () => Promise<GetServiceResponse> = () => axios.get(endpoints.filter());
export const postService: (body: any) => Promise<PostServiceResponse> = (body: any) => axios.post(endpoints.filter(), body);
 

GET Service Call

function* getServiceSaga({ searchQuery }) {
  try {
    const { filter } = yield serviceWrapperSaga(getService)
    //....
  } catch (e) {
    console.log(e);
  }
}

POST Service Call

function* postServiceSaga({ searchQuery }) {
  try {
    const { filter } = yield serviceWrapperSaga(postService, {test: 'TEST'})
    //....
  } catch (e) {
    console.log(e);
  }
}

Handling Errors

Loading .. ;)
1.0.9

4 years ago

1.0.8

4 years ago

1.0.7

4 years ago

1.0.6

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago