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 🙏

© 2025 – Pkg Stats / Ryan Hefner

retransmitter

v0.2.1

Published

Async-friendly stateful React containers

Downloads

9

Readme

Transmitter

Async declarative reactive component-based (and other buzzwords) programming made easy.

Inspired by Relay. An attempt to create unified container solution.

NB: For now Transmitter depends on Rx (used as peer dependency).

Introduction

The idea of transmitter for UI is heavily inspired by A Mathematical Theory of Communication.

Installation

Install via NPM:

npm install --save retransmitter

Require the lib in your code:

import Transmitter from 'retransmitter';

Still using that old syntax?

var Transmitter = require('retransmitter');

NB: If you're NPM3 user please make sure you have these dependencies installed. I'll make these dependencies as own dependencies after NPM3 will be used widely.

npm install --save react react-dom rx

How it works

Just combineLatest operator magic. See more on ReactiveX.io.

API

Transmitter.create(Component, options)

  • Component — React Component or enum {pending, success, failure} of React Components.
  • options — object with next definitions:
    • initialVariables (optional) — an object with predefined variables for fragments.
    • fragments — set of functions that are fetching data from different sources. Names should be the same as follow prop names in the component you're using.
    • shouldContainerUpdate() (optional) — lifecycle hook that receives new props and returns true or false.

Transmitter.wrap(asyncFunction)

TBD

Transmitter.fromStore(store)

Creates an Observable from Store (Flux, Redux, etc). Store is an object that provides next API:

  • getState() — returns current state of this store.
  • subscribe() — adds a change listener and returns unsubscribe function.

Transmitter.fromPromise(promise)

This method is not required for using. If you use native Promises you can just return them as fragment's result.

See more in RxJS docs.

Transmitter.fromValue(value)

Use if you want to pass dummy or constant data via fragment. If you want to pass event hook (ie Flux's Action Creator) you don't need to use fromValue.

See more in RxJS docs.

Examples

function Item({key, title, description}) {
	return (
		<article>
			<h2>{title}</h2>
			<p>{description}</p>
			<p><a href={`/articles/${key}`}>Read more</a></p>
		</article>
	);
}
function ItemsList({items = []}) {
	return (
		<section>
			{items.map(({id, title, description}) =>
				<Item key={id} title={title} description={description} />
			)}
		</section>
	);
}
ItemsListContainer = Transmitter.create(ItemsList, {
	items() {
		return fetch('/items')
			.then(r => r.json());
	}
});
ReactDOM.render(<ItemsListContainer />, ...);

Multiple choise component

ItemsListContainer = Transmitter.create({
	pending: LoadingSpinner,
	success: ItemsList,
	failure: ItemsListError
}, {
	items() {
		return fetch('/items')
			.then(r => r.json());
	},
	query() {
		return Transmitter.fromStore(QueryStore);
	},
	onSelect() {
		return ItemsActions.selectItem;
	}
});
--[items]-------------------------------|> (from items fragment)
------"query"----------"query2"---------|> (from query store)
------{items, query}---{items, query2}--|> (result that will be passed to ItemsList)

When <ItemsListContainer /> is added to the view pending component will be rendered at first. pending component will be rendered with props:

  • onAbort — the callback that used as event hook and dispose all fragments fetching processes.

After loading is finished success or failure component will be rendered (depends on results). failure component will receive next props:

  • error — the error instance that will be received in failed getter.
  • onRetry — the callback that can be attached as event hook and will restart data fetching.

Support

  • [x] Promises
  • [x] Observables
  • [x] Falcor (since it uses Promises and Observables)
  • [x] Stores (Flux, Redux) (See Transmitter.fromStore())
  • [ ] CSP channels
  • [ ] Relay