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

udeo

v0.0.0-alpha.6

Published

RxJS based state streams

Downloads

1

Readme

udeo (experimental)

Udeo is a RxJS 5 based state stream container. It is comparable to Redux, where the store is instead modelled as a collection of state streams (one per module). Unidirectional data flow in Udeo is obtained with RxJS (instead of the event emitter approach of past and present Flux implementations), where each module composes its own data flow.

The reasoning behind using RxJS for unidirectional data flow is given here: https://medium.com/@markusctz/state-streams-and-react-7921e3c376a4

A state stream is effectively the result of reducing a stream of actions. It boils down to the simple flow:

Action Stream -> Reduce -> State Stream

Install

NOTE: This has a peer dependencies of [email protected].*

npm install --save udeo

Usage

Please read the introduction on Medium: https://medium.com/@markusctz/state-streams-and-react-7921e3c376a4

createStore(moduleDefinitions, [preloadedState])

Creates a store which houses a collection of state streams. It adds a state stream for each module definition provided.

Arguments

  1. moduleDefinitions (Object): Each module definition provides two functions used to form the module's state stream.
  2. [preloadedState] (Object): The initial state. Can be used to hydrate the store from state generated by the server in universal apps.

Returns

(Object): An Udeo store that allows you to subscribe to the state streams, dispatch actions and read the current state of the application.

Ajax Example

import { createStore } from 'udeo';

/**
 * @typedef moduleDefinition
 * @type {Object}
 * @property {Function} flow - Provides the module's data flow.
 * Receives the raw action stream as argument and returns an array of action streams to be reduced.
 * @property {Function} reducer - The reducer of the provided flow.
 * Returns the next version of the module's state (a plain old reducer function).
 */
const searchModule = {
  // dispatch$ is the stream through which dispatched actions flow - the raw action stream
  flow(dispatch$) {
    // Filter the raw action stream into a search stream
    const search$ = dispatch$.filterAction('SEARCH');

    // Transform the search stream into a search response stream
    const searchResponse$ = search$
      // Grab the query from the payload
      .pluckPayload()
      // Go to the server with the query (integrates with promises)   
      .flatAjax(ProductService.search)
      // Map the server response to the response action
      .mapAction('SEARCH_RESPONSE');

    // The action streams to reduce state with
    return [
      search$,
      searchResponse$,
    ];
  },
  // Plain old reducer function - reduces state for provided data flow
  reducer(state = { searching: false, results: [] }, action) {
    switch (action.type) {
    case 'SEARCH':
      return {
        ...state,
        searching: true,
      };
    case 'SEARCH_RESPONSE':
      return {
        ...state,
        searching: false,
        results: action.payload,
      };
    default:
      return state;
    } 
  }
};

const someOtherModule = { ... };

// Creates the Udeo store which houses a collection of state streams
// Exposes an API: { dispatch, getState$, getState, setMiddleware, ... }
const store = createStore({ searchModule, someOtherModule });

// Manually subscribe to a particular modules state stream. A view binding library like 
// React-Udeo would usually be used instead of manually subscribing
store.getState$('searchModule').subscribe(state => {
  console.log('Search state: ', state);
});
// >_ Search state: { searching: false, results: [] }

// Dispatches the action into the raw action stream
store.dispatch({ type: 'SEARCH', payload: 'Foo bar' });
// >_ Search state: { searching: true, results: [] }
// Searching...
// >_ Search state: { searching: false, results: [20] }

React Bindings

https://github.com/mcoetzee/react-udeo