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

refract-most

v5.0.0-rc.0

Published

Refract bindings for React with Most: harness the power of reactive programming to supercharge your components!

Downloads

49

Readme

  • :bowling: Decentralised: attach effects and side-effects to your components, for better code splitting results
  • :sunrise: Gradual: use on an existing component today, throughout your app tomorrow
  • :rocket: Reactive: leverage the power and benefits of reactive programming
  • :floppy_disk: Tiny: less than 2Kb minified and gzipped
  • :pencil: Typed: written in TypeScript, fully typed integrations
  • :zap: Universal: supports React, React Native, Inferno and Preact

Refract makes reactive programming possible in React, React Native, Preact and Inferno, with only a single higher-order component or a single hook! You can choose to start using a tiny bit of reactive programming, or go full reactive. Refract allows you to:

We also provide a Redux integration, which can serve as a template for integrations with other libraries. With a single HoC, you can fully replace libraries like recompose, redux-observable, and react-redux to name a few!

Why?

Component-based architecture and functional programming have become an increasingly popular approach for building UIs. They help make apps more predictable, more testable, and more maintainable.

However, our apps don't exist in a vacuum! They need to handle state, make network requests, handle data persistence, log analytics, deal with changing time, and so on. Any non-trivial app has to handle any number of these effects. Wouldn't it be nice to cleanly separate them from our apps?

Refract solves this problem for you, by harnessing the power of reactive programming. For an in-depth introduction, head to Why Refract.

Installation

npm install --save refract-most

Refract is available for a number of reactive programming libraries. For each library, a Refract integration is available for React, Inferno, Preact and Redux.

Available packages:

| | React | Inferno | Preact | Redux | | --- | --- | --- | --- | --- | | Callbag | refract-callbag | refract-inferno-callbag | refract-preact-callbag | refract-redux-callbag | | Most | refract-most | refract-inferno-most | refract-preact-most | refract-redux-most | | RxJS | refract-rxjs | refract-inferno-rxjs | refract-preact-rxjs | refract-redux-rxjs | | xstream | refract-xstream | refract-inferno-xstream | refract-preact-xstream | refract-redux-xstream |

The Gist

The example below uses refract-rxjs to send data to localstorage.

Every time the username prop changes, its new value is sent into the stream. The stream debounces the input for two seconds, then maps it into an object (with a type of localstorage) under the key value. Each time an effect with the correct type is emitted from this pipeline, the handler calls localstorage.setItem with the effect's name and value properties.

const aperture = component => {
    return component.observe('username').pipe(
        debounce(2000),
        map(username => ({
            type: 'localstorage',
            name: 'username',
            value: username
        }))
    )
}

const handler = initialProps => effect => {
    switch (effect.type) {
        case 'localstorage':
            localstorage.setItem(effect.name, effect.value)
            return
    }
}

const WrappedComponent = withEffects(aperture, { handler })(BaseComponent)

The example demonstrates uses the two building blocks used with Refract - an aperture and a handler - and shows how they can be integrated into a React component via the withEffects higher-order component.

Aperture

An aperture controls the streams of data entering Refract. It is a function which observes data sources within your app, passes this data through any necessary logic flows, and outputs a stream of effect values in response.

Handler

A handler is a function which causes side-effects in response to effect values.

Learn Refract

Documentation

Documentation is available at refract.js.org. We aim to provide a helpful and thorough documentation: all documentation files are located on this repo and we welcome any pull request helping us achieve that goal.

Examples

We maintain and will grow over time a set of examples to illustrate the potential of Refract, as well as providing reactive programming examples: refract.js.org/examples.

Examples are illustrative and not the idiomatic way to use Refract. Each example is available for the four reactive libraries we support (RxJS, xstream, Most and Callbag), and we provide links to run the code live on codesandbox.io. All examples are hosted on this repo, and we welcome pull requests helping us maintaining them.

Contributing

We welcome many forms of contribution from anyone who wishes to get involved.

Before getting started, please read through our contributing guidelines and code of conduct.

Links

Logo

The Refract logo is available in the Logo directory.

License

Refract is available under the MIT license.

Discuss

Everyone is welcome to join our discussion channel - #refract on the Reactiflux Discord server.

Talks

Articles