never write another CRUD redux action!
this module helps you use feathers
, redux
, and tcomb
.
const createModule = require('feathers-action')
const createCid = require('cuid')
const module = createModule('cats')
// module.actions
// module.epic
// module.updater
feathers-reactive
: must add plugin to feathers app / clientredux-observable
: must add middleware to redux store
options
:
name
methods
- TODO
idField
actions
: object where keys are method names (find
,get
,create
, ...)updater
:action => state => nextState
epic
:(action, action$, store) => nextAction$
where modules
is an object where key is name
and value is module
as above.
each action creator receives a cid
(client-generated id) as the first argument.
all subsequent arguments for feathers methods are the same as the corresponding methods on the feathers service.
cancels a long-running subscription as in find
or get
.
sets the given key as value in the corresponding redux state.
to unset (remove key), value is undefined
.
see "updater" in redux-fp
: action => state => nextState
see "epic" in redux-observable
: (action, action$, store) => nextAction$
must pass in { feathers }
as deps
to createEpicMiddleware
// client
const Feathers = require('feathers/client')
const feathersSockets = require('feathers-socketio/client')
const feathersRx = require('feathers-reactive')
const Rx = require('rxjs')
const socket = io()
const feathers = Feathers()
.configure(feathersSockets(socket))
.configure(feathersRx(Rx))
// store
const { createStore, applyMiddleware } = require('redux')
const { createEpicMiddleware } = require('redux-observable')
const rootEpic = require('./epic')
const rootUpdater = require('./updater')
const epicMiddleware = createEpicMiddleware(rootEpic, {
dependencies: { feathers }
})
const store = createStore(
(state, action) => rootUpdater(action)(state),
applyMiddleware(epicMiddleware)
)
With npm installed, run
$ npm install feathers-action --save
feathers-action was inspired by..
- redux
- feathers
The Apache License
Copyright © 2017 Michael Williams
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.