npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

aerux

v4.2.0

Published

An easy way to use redux with react

Downloads

70

Readme

aerux

node npm license Build Status Standard - JavaScript Style Guide Coverage Status codecov Known Vulnerabilities

An easy way to use redux with react

Install

npm install aerux

Use

// es6
import { createStore, createModel, connect, actions } from 'aerux'
// or
const { createStore, createModel, connect, actions } = require('aerux')

const store = createStore(options)

// reducers/count.js
import { createModel } from 'aerux'

export const { actions, reducer } = createModel({
  namespace: 'count',
  state: 0,
  actions: {
    plus: count => count,
    minus: count => count
  },
  reducers: {
    plus: (state, { payload }) => state + payload,
    minus: (state, { payload }) => state - payload
  }
})

// Count.jsx
import { connect } from 'aerux'

class Count extends React.Component {
  render() {
    // ...
  }
}

export default connect(state => ({
  count: state.count
}))(Count)

// App.jsx
import { Provider } from 'react-redux'
import Count from './Count'

const App = () => (
  <Provider store={store}>
    <Count />
  </Provider>
)

API

createStore

create store with redux.createStore

createStore({
  middlewares,
  enhancers,
  compose,
  state,
  reducers
})

| name | description | type | default | optional | | ------------- | ---------------------- | ------------------- | --------------- | -------- | | middlewares | redux middleware | Array | [] | true | | enhancers | redux enhancer | Array | [] | true | | compose | used for redux devtool | - | redux.compose | true | | state | initial state | any | {} | true | | reducers | initial reducers | ReducersMapObject | {} | true |

createModel

create model with redux-actions

const { actions, reducer } = createModel({
  namespace,
  state,
  actions,
  reducers
})

| name | description | type | default | optional | | ----------- | --------------- | ------------------------------------------------------------------------------------------------------------- | ----------- | -------- | | namespace | namespace | string | undefined | false | | state | initial state | any | null | true | | actions | redux actions | ActionMap<Payload, Meta> | true | | reducers | action handlers | ReduxCompatibleReducer<State, Action<Payload>> | ReduxCompatibleReducerMeta<State, Action<Payload>, any> | {} | true |

Note: if you create model after create store, you can use actions from aerux directly

Notes

  • namespace: if you present namespace and store is created, reducer will be auto injected to store

  • actions: actionCreator is created by redux-actions

  • reducers: created by redux-actions

actions

action which created in createModel will be auto injected to it, you can call it directly

actions[namespace][actionName]

actions.count.add()

connect

connect store and component like redux.connect, but much better

connect(mapStateToProps, actions)(Component)

Note: you can use actions from aerux directly, no connect actions need, ex:

import { actions } from 'aerux'

class DemoComponent extends React.Component {
  add = () => {
    actions.count.add()
  }
  render() {
    // ...
  }
}

connect(mapStateToProps)(DemoComponent)

store.actions[namespace][actionName]

another alias for actions

store.actions.count.add()

store.injectReducer

This function is used for async inject reducer, for code-splitting

store.hotReplaceReducer

This function is used for HMR when build application with Webpack