arcln / redux-feathers

Wrap Feathers services to use them as redux actions and put their result into the state.

Home Page:https://www.npmjs.com/package/redux-feathers

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

redux-feathers

Wrap Feathers services to use them as redux actions and put their result into the state.

This package directly depends on redux-saga-wrapper.

Installation

npm i redux-saga-wrapper redux-feathers --save
# or
yarn add redux-saga-wrapper redux-feathers

How to use

Register Feathers actions:

import { createStore } from 'redux-saga-wrapper';
import { createFeathersActions } from 'redux-feathers';

const feathersClient = feathers();

const onFeathersError = console.error;
const actions = createFeathersActions(feathersClient, onFeathersError);

const store = createStore({}, actions);

// ... use store as usual

Use Feathers in your components:

import { mapDispatchToProps } from 'redux-feathers';

class App extends React.Component {

  // ...

  componentDidMount() {
    this.props.service('users').find({ $limit: 10 });
  }

  // ...
}

const mapStateToProps = state => ({
  users: users && users.list,
});

export default connect(mapStateToProps, mapDispatchToProps)(App);

About

Wrap Feathers services to use them as redux actions and put their result into the state.

https://www.npmjs.com/package/redux-feathers

License:MIT License


Languages

Language:JavaScript 100.0%