reresource
👋
Manage resources in redux maintaining a sane mind
Install
yarn add reresource
Usage
Configure your store
import applyMiddleware combineReducers createStore from "redux";import reducer as resources saga as resourceSaga from "reresource";import createSagaMiddleware from "redux-saga"; { return state;} const sagaMiddleware = ; ;sagaMiddleware;
Fetch resource
import React from 'react';import getResource fetchResource from 'reresource'; Component { thisprops; } { if thispropsusererror return <div>Error loading user</div>; if thispropsuserloading return <div>loading...</div>; return <div>thispropsuserdatafullName</div>; } const mapStateToProps = state props user: ; const mapDispatchToProps = fetchResource;
Delete resource
import React from 'react';import getResource fetchResource deleteResource from 'reresource'; Component { thisprops; } { const user = thisprops; thisprops; } { if thispropsusererror return <div>Error loading user</div>; if thispropsuserloading return <div>loading...</div>; return <div>thispropsuserdatafullName<button =>Delete</button></div>; } const mapStateToProps = state props user: ; const mapDispatchToProps = fetchResource deleteResource;
Docs
Run tests
yarn test
Author
👤 Rodrigo Correa Alves
Show your support
Give a ⭐️ if this project helped you!
📝 License
Copyright © 2019 Rodrigo Correa Alves.
This project is MIT licensed.