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

fluxxor-components

v0.1.0

Published

Higher-order components for Fluxxor

Downloads

3

Readme

Fluxxor Components

Build Status

Higher-order components for use with Fluxxor. These are intended to replace FluxMixin and StoreWatchMixin when using ECMAScript 2015 classes.

API

createContext(flux: Flux): Component

Returns a new component whose elements pass the given Flux instance down as a context. Every child element of this new component will have the Flux available as the context prop named flux.

Intended to replace FluxMixin.

Example

/* Create the flux instance. */
const flux = new Fluxxor.Flux(...);
/* Create the new component with a flux instance as context. */
const FluxContext = createFluxContext(flux);

class App extends React.Component {
  /* Declare that we accept the Flux instance from the context. */
  static get contextTypes() {
    return {
      flux: React.PropTypes.object
    };
  }

  render() {
    /* Use the flux instance. */
    const {flux} = this.context;
    const actionNames = Object.keys(flux.actions);
    return <ul>{actionNames.map(name =>
      <li key={name}>{name}</li>
    )}</ul>;
  }
}

/* Render the instance: */
React.render(
  document.getElementById('react'),
  <FluxContext>
    <App />
  </FluxContext>
);

watchStores(Component, ...StoreNames: String, onChange: (Flux) => Object): Component

Watches the given stores, and passes the updates state as props to the given component. Use the returned component as if it was the given component; except it watches Fluxxor stores.

That is, it returns a component that wraps the given React component and calls onChange when any of the given stores are changed. The return of onChange is used to update the state; all of this state is subsequently passed to the wrapped component as props, along with its original props. Assumes flux exists in the context (i.e., in the manner that createFluxContext() would provide it) or the Flux instance passed as a prop named flux.

Intended to replace StoreWatchMixin.

/* We're bringin' it back! */
class Blink extends React.Component {
  render() {
    const {children, speed} = this.props;
    const styles = {
      animation: `blink ${speed} steps(2, start) infinite`
    };
    return <div style={styles}>{children}</div>;
  }
}

/* Get the data from the Twitter store. */
const BlinkFromTwitter = watchStores(Blink, 'twitter', (flux) => ({
  children: flux.store('twitter').getLatestTweet()
}));

/* Render the instance: */
React.render(
  document.getElementById('react'),
  <FluxContext>
    <BlinkFromTwitter speed="250ms" />
  </FluxContext>
);