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 🙏

© 2026 – Pkg Stats / Ryan Hefner

react-knockout

v1.0.6

Published

Utilities to connect Knockout observables to React components

Readme

react-knockout

Build Status npm version MIT Licence

Install

npm install --save react-knockout

Demo

Live demo: https://vaaralav.github.io/react-knockout

Source code: example/src

Sandbox: https://codesandbox.io/s/github/vaaralav/react-knockout/tree/master/example

Usage

KoSubscribe- Subscribe to observables on the go

import React, { Component } from 'react';
import counter from './counter'; // ko.observable

import { KoSubscribe } from 'react-knockout';

class Example extends Component {
  render() {
    return (
      <KoSubscribe
        subscribe={{
          counter,
        }}
        render={({ counter }) => <pre>{counter}</pre>}
      />
    );
  }
}

KoProvider - Handle subscriptions at high level and connect where needed

import React, { Component } from 'react';
import counter from './counter'; // ko.observable
import status from './status'; // ko.observable
import queue from './queue'; // ko.observable

import {
  KoProvider,
  ConnectedKoSubscribe,
  withKoSubscribe,
} from 'react-knockout';

function Status({ state: { status = 'Unknown', queue = [] } }) {
  return (
    <div>
      <h3>{status}</h3>
      <ol>{queue.map(val => <li>{val}</li>)}</ol>
    </div>
  );
}

const ConnectedStatus = withKoSubscribe(Status);

class Example extends Component {
  render() {
    return (
      <KoProvider
        subscribe={{
          counter,
          status,
          queue,
        }}
      >
        <div>
          <ConnectedKoSubscribe
            render={({ counter }) => <pre>{counter}</pre>}
          />
          <ConnectedStatus />
        </div>
      </KoProvider>
    );
  }
}

API

<KoSubscribe subscribe render>

Makes subscribed ko.observable changes to call the render function provided as render or children prop.

Props

  • subscribe(Object of ko.observables): The ko.observables you want to subscribe.
  • render or children (Function): A function that gets the values of the subscribed observables as the first parameter and returns JSX.

Example

Using function as children.

ReactDOM.render(
  <KoSubscribe
    subscribe={{
      greeting: ko.observable('Hello'),
      name: ko.observable('world'),
    }}
  >
     {({ greeting, name }) => `${greeting}, ${name}!`}
  </KoSubscribe>,
  element,
);

Using render prop.

ReactDOM.render(
  <KoSubscribe
    subscribe={{
      greeting: ko.observable('Hello'),
      name: ko.observable('world'),
    }}
    render={({ greeting, name }) => `${greeting}, ${name}!`}
  />,
  element,
);

<KoProvider subscribe>

Makes the subscribed ko.observables available to withKoSubscribe and <ConnectedKoSubscribe> in the component hierarchy.

Props

  • subscribe(Object of ko.observables): The ko.observables you want to subscribe.
  • children (ReactElement): The root of your component hierarchy.

Example

ReactDOM.render(
  <KoProvider subscribe={subscriptions}>
      <MyRootComponent />
  </KoProvider>,
  element,
);

<ConnectedKoSubscribe render>

A connected component that gives access to observables subscribed with <KoProvider> above in the component hierarchy.

Props

  • render or children (Function): A function that gets the values of the subscribed observables as the first parameter and returns JSX.

Example

ReactDOM.render(
  <KoProvider
    subscribe={{
      greeting: ko.observable('Hello'),
      name: ko.observable('world'),
    }}
  >
    <ConnectedKoSubscribe>
      {({ greeting, name }) => `${greeting}, ${name}!`}
    </ConnectedKoSubscribe>
  </KoProvider>,
  element,
);

withKoSubscribe(Component)

A higher-order component that gives access to observables subscribed with <KoProvider> above in the component hierarchy.

Arguments

  • Component (ReactComponent): A component that will receive the values of subscribed observables as state prop.

Example

const Greeter = ({ state }) => `${state.greeting}, ${state.name}!`;
const ConnectedGreeter = withKoSubscribe(Greeter);

ReactDOM.render(
  <KoProvider
    subscribe={{
      greeting: ko.observable('Hello'),
      name: ko.observable('world'),
    }}
  >
    <ConnectedGreeter />
  </KoProvider>,
  element,
);

License

MIT © Ville Vaarala