Project Name | Stars | Downloads | Repos Using This | Packages Using This | Most Recent Commit | Total Releases | Latest Release | Open Issues | License | Language |
---|---|---|---|---|---|---|---|---|---|---|
Redux Api | 498 | 61 | 9 | 3 years ago | 71 | February 25, 2020 | 31 | mit | JavaScript | |
Flux REST API for redux infrastructure | ||||||||||
Tectonic | 472 | 3 | 1 | 5 years ago | 42 | August 16, 2017 | 45 | JavaScript | ||
A declarative REST data loader for React and Redux. Docs @ | ||||||||||
Admin On Rest | 375 | 5 years ago | 64 | May 24, 2019 | 13 | mit | JavaScript | |||
A frontend framework for building admin SPAs on top of REST services, using React and Material Design. | ||||||||||
Tourism Demo | 278 | 4 years ago | 2 | Dart | ||||||
Flutter app backed by Redux, shows animations, internationalization (i18n), ClipPath, fonts and others... | ||||||||||
Lexi | 263 | 7 years ago | 4 | mit | JavaScript | |||||
A single-page WP React, Redux, React Router, WP REST API theme. | ||||||||||
Express React Boilerplate | 259 | 2 months ago | 31 | JavaScript | ||||||
Express, MySQL, React/Redux, NodeJs Application Boilerplate | ||||||||||
Flutter Redux Starter | 252 | 4 years ago | 19 | Dart | ||||||
Starter project and code generator for Flutter/Redux | ||||||||||
Redux Rest Resource | 190 | 9 | 1 | 2 months ago | 95 | October 15, 2020 | mit | TypeScript | ||
Seamless REST interaction for Redux | ||||||||||
Backbone Redux | 185 | 1 | 2 | 5 years ago | 8 | February 14, 2017 | 5 | mit | JavaScript | |
Easy way to keep your backbone collections and redux store in sync. | ||||||||||
Redux Rest | 181 | 4 | 1 | 7 years ago | 8 | March 27, 2016 | 8 | mit | JavaScript | |
Automatically create Redux action constants, action creators, and reducers for your REST API |
Flux REST API for redux infrastructure
redux-api
solves the problem of writing clients to communicate with backends. It generates actions and reducers for making AJAX calls to API endpoints. You don't need to write a lot of boilerplate code if you use redux
and want to exchange data with server.
Inspired by Redux-rest and is intended to be used with Redux.
See DOCS.md for API documentation.
With npm:
npm install redux-api --save
With bower:
bower install redux-api --save
If you don't use tools like webpack, browserify, etc and you want to load redux-api manually, the best way to add redux-api to your project is:
<script src="(...)/redux-api.min.js"></script>
<script>
window.ReduxApi = window["redux-api"];
// or
var ReduxApi = window["redux-api"];
// initialization code
</script>
=======
redux-api
doesn't bind you to a technology to make AJAX calls. It uses configurable adapters
- a pretty simple function which receives 2 arguments: endpoint
and options
, and returns a Promise as result. The default adapter uses isomorphic-fetch, and has an implementation like this:
function adapterFetch(url, options) {
return fetch(url, options);
}
However, you are not tied to using isomorphic-fetch. For instance, if you prefer to use jQuery, you can use the following adapter:
function adapterJquery(url, options) {
return new Promise((success, error)=> {
$.ajax({ ...options, url, success, error });
});
}
This implementation allows you to make any request and process any response.
And of course you have to set up adapter to your redux-api
instance before using.
reduxApi(....).use("fetch", adapterFetch)
=======
examples/isomorphic - React + Redux + React-Router + Redux-api with webpack and express + github API
rest.js
import "isomorphic-fetch";
import reduxApi, {transformers} from "redux-api";
import adapterFetch from "redux-api/lib/adapters/fetch";
export default reduxApi({
// simple endpoint description
entry: `/api/v1/entry/:id`,
// complex endpoint description
regions: {
url: `/api/v1/regions`,
// reimplement default `transformers.object`
transformer: transformers.array,
// base endpoint options `fetch(url, options)`
options: {
headers: {
"Accept": "application/json"
}
}
}
}).use("fetch", adapterFetch(fetch));
index.jsx
import React, {PropTypes} from "react";
import { createStore, applyMiddleware, combineReducers } from "redux";
import thunk from "redux-thunk";
import { Provider, connect } from "react-redux";
import rest from "./rest"; //our redux-rest object
const createStoreWithMiddleware = applyMiddleware(thunk)(createStore);
const reducer = combineReducers(rest.reducers);
const store = createStoreWithMiddleware(reducer);
function select(state) {
return { entry: state.entry, regions: state.regions };
}
class Application {
static propTypes = {
entry: PropTypes.shape({
loading: PropTypes.bool.isRequired,
data: PropTypes.shape({
text: PropTypes.string
}).isRequired
}).isRequired,
regions: PropTypes.shape({
loading: PropTypes.bool.isRequired,
data: PropTypes.array.isRequired
}).isRequired,
dispatch: PropTypes.func.isRequired
};
componentDidMount() {
const {dispatch} = this.props;
// fetch `/api/v1/regions
dispatch(rest.actions.regions.sync());
//specify id for GET: /api/v1/entry/1
dispatch(rest.actions.entry({id: 1}));
}
render() {
const {entry, regions} = this.props;
const Regions = regions.data.map((item)=> <p>{ item.name }</p>)
return (
<div>
Loading regions: { regions.loading }
<Regions/>
Loading entry: {entry.loading}
<div>{{ entry.data.text }}</div>
</div>
);
}
}
const SmartComponent = connect(select)(Application);
React.render(
<Provider store={store}>
<SmartComponent />
</Provider>,
document.getElementById("content")
);