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

reflux-connect

v0.2.0

Published

Higher order Components creator for Reflux

Downloads

8

Readme

Reflux connect

Higher order Components creator for Reflux

Build Status Coverage NPM Dependencies License

Usages

Actions & Stores

Only support the Reflux.connect way, actions will be the same, but stores should be use as reflux.connect, see more https://github.com/reflux/refluxjs#using-refluxconnect

Components

import React from 'react';
import refluxConnect from 'reflux-connect';

import storeA from '../stores/storeA';
import storeB from '../stores/storeB';
import commonActions from '../actions/commonActions';

const componentConnect = refluxConnect({
  storeA: storeA,
  storeB: storeB   
})((state) => {
  return {
    storeA: state.storeA,
    storeB: state.storeB   
  }
}, {
  fetchData: commonActions.fetchData
});

class Component extends React.Component {
  static propTypes = {
    storeA: React.PropTypes.object
    storeB: React.PropTypes.object
    fetchData: React.PropTypes.func.isRequired
  }
  
  render() {
    return null;
  }
}

export default componentConnect(Component)

refluxConnect Details

refluxConnect(stateKeyMap)([mapStateToProps], [mapActionsToProps], [mergeProps], [options])

same design as https://github.com/rackt/react-redux/blob/master/docs/api.md#connectmapstatetoprops-mapdispatchtoprops-mergeprops-options

Connects a React component to reflux stores and actions.

It does not modify the component class passed to it. Instead, it returns a new, connected component class, for you to use.

However, we should create a stateKeyMap for the connect state. Once we created the stateKeyMap, the Component will be subscribed to the related stores.

Arguments:

[mapStateToProps(state, [ownProps]): stateProps] (Function): If specified, the component will subscribe to reflux stores updates. Any time it updates, mapStateToProps will be called. Its result must be a plain object, and it will be merged into the component’s props. If ownProps is specified as a second argument, its value will be the properties passed to your component, and mapStateToProps will be re-invoked whenever the component receives new props. If you omit it, will return the created state object.

[mapActionsToProps(state, [ownProps]): actionProps] (Object or Function): If an object is passed, each function inside it will be assumed to be an action creator. An object with the same function names, will be merged into the component’s props. If a function is passed, it will be given dispatch. It’s up to you to return an object that somehow uses dispatch to bind action creators in your own way. If you omit it, will return empty object.

[mergeProps(stateProps, actionProps, ownProps): props] (Function): If specified, it is passed the result of mapStateToProps(), mapActionsToProps(), and the parent props. The plain object you return from it will be passed as props to the wrapped component. You may specify this function to select a slice of the state based on props, or to bind action creators to a particular variable from props. If you omit it, Object.assign({}, ownProps, stateProps, actionProps) is used by default.

[options] (Object) If specified, further customizes the behavior of the connector.

[pure = true] (Boolean): If true, implements shouldComponentUpdate and shallowly compares the result of mergeProps, preventing unnecessary updates, assuming that the component is a “pure” component and does not rely on any input or state other than its props and the selected store’s state. Defaults to true.

[withRef = false] (Boolean): If true, stores a ref to the wrapped component instance and makes it available via getWrappedInstance() method. Defaults to false.

Returns

Static Properties

  • WrappedComponent (Component): The original component class passed to connect().

Static Methods

All the original static methods of the component are hoisted.

Instance Methods

getWrappedInstance(): ReactComponent

Returns the wrapped component instance. Only available if you pass { withRef: true } as part of the connect()’s fourth options argument.