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

react-pubsub

v0.5.0

Published

PubSub abstraction layer for React, should support any compliant pub-sub libray.

Downloads

20

Readme

React-PubSub

React-PubSub is an abstraction layer for React. The idea is to enable PubSub communication between React components, completely decoupling the PubSub layer and its consumption. React-PubSub enable support to any compliant PubSub libray via custom adapters.

The library is just 14kB and comes with an internal PubSub implementation ready to be used out of the box.

semantic-release build status npm version npm downloads Commitizen friendly

Installation

React-Pubsub requires React 0.14 or later.

Using npm based module bundlers

If you are using webpack or browserify to manage the project dependencies:

npm install --save react-pubsub

Using other build systems

If you are using bower or other build system an UMD build is available at npmcdn.com:

Using the UMD build react-pubsub is available as a global object.

React Native

React-SubPub should work without problems with React Native, but we've not already tried it.

Quick Start

React-PubSub offers 3 elements:

  • a PubSub Wrapper
  • a PubSub Provider
  • a PubSub Connector

Provider Component

To start using it you must create a PubSub Wrapper and passit to a PubSub Provider. The Provider will expose to its children the PubSub Wrapper API.

// App.js

import React, { Component } from 'react';
import { createPubSub, PubSubProvider } from 'react-pubsub';
import ConnectedComponent from './ConnectedComponent';

const pubSubCore = createPubSub();

export default class App extends Component {
  render() {
    return (
      <PubSubProvider pubSubCore={pubSubCore}>
        <div>{ .... }</div>
      </PubSubProvider>
    );
  }
}

Connector Component

Any children of PubSubProvider who require access to the PubSub API should be wrapped by a PubSub Connector. The connector will pass pubSub as prop to its child component.

Create the Connected Component:

// ConnectedComponent.js

import React, { Component, PropTypes } from 'react';
import { createPubSubConnector } from 'react-pubsub';

class ConnectedComponent extends Component {
  componentDidMount() {
    const { pubSub } = this.props;
    // use PubSub API
  }

  render() {
    return (
      <div>Connected Component</div>
    );
  }
}

ConnectedComponent.propTypes = {
  pubSub: subscriptionShape.isRequired,
};

export default createPubSubConnector()(ConnectedComponent);

Attention createPubSubConnector must be invoked twice, first with configuration parameters and the returned function with the component to be wrapped.

Remove subscribed events

The PubSub Connector automatically remove all subscription when the component will unmount.

Documentation

More info coming soon...

License

MIT