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

oddstream

v8.0.3

Published

A simple Redux-type library entirely based on RxJS streams. This is an easy way to introduce a stream-based unidirectional dataflow into your app.

Downloads

15

Readme

oddstream

Greenkeeper badge

One Direction Data Stream.

Dead simple Redux with RxJS streams. This is an easy way to introduce a stream-based unidirectional dataflow into your app.

Install

npm install oddstream

Usage

import { createOddstream } from 'oddstream';

const oddstream = createOddstream();

Dispatch Actions

In your components dispatch actions by passing the action constant and optionally an action payload. The payload can be any value.

oddstream.dispatch({ type: 'SOME_ACTION', payload: { some: 'state' } });

Create A State Stream Based On Reducers

In a file that you could call Store, create and expose state streams for your components by passing the respective reducers.

Here is also the place where you can combine state streams if they depend on one another.

// A collection of reducers.
const itemListReducers = {
  deleteItem: (action, state) => state
    .filter(item => state.filter(item.id !== action.payload.id)),
    
  addItem: (action, state) => [...state, action.payload],
  // ...
};

itemListState$ = oddstream.createState$(itemListReducers, initialState);

In your component you can now subscribe to the component state stream:

itemListState$.subscribe(state => console.log(state));

Trigger Side Effects

You can trigger your side effects similar to redux-observable by listening to the actions stream, triggering your side effect and return a new action.

Each side effect is a function and has to be passed to oddstream.runSideEffects.

The action that the result of each side effect maps to

// An imaginary API.
const serverApi = new serverApi();

const sideEffect1 = action$ => action$
  .filter(action => action.type === 'DELETE_ITEM')
  .switchMap(action => serverApi.deleteItem(action.payload))
  .map(response => ({ type: 'RECEIVE_ITEMS', payload: response }))
  .catch(response => ({ type: 'DELETE_ITEM_ERROR', payload: response.error });

const sideEffect1 = action$ => action$
  .filter(action => action.type === 'ADD_ITEM')
  .switchMap(action => serverApi.addItem(action.payload))
  .map(response => ({ type: 'RECEIVE_ITEMS', payload: response }))
  .catch(response => ({ type: 'ADD_ITEM_ERROR', payload: response.error });

oddstream.runSideEffects(sideEffect1, sideEffect2);

License

MIT © Kahlil Lechelt