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

apostate

v0.1.0-beta.5

Published

Reactive state management.

Downloads

15

Readme

Experimental

Apostate is an experiment in reactive application-state management.

Adds approximately 2.6Kb to your client-side bundle, when compiled and minified using a bundler such as webpack.

Routing

Apostate exposes express-style routing, via adapters. Each route has one or more handler, with a signature function( req, res, next ) { ... }. Several Apostate-specific methods are exposed via the req and res objects.

const router = Router({ adapter });

router.get( '/', ( req, res ) => {
  const tasks = [
    { label: 'Clean the gutters.', completed: false },
    { label: 'Pickup milk', completed: false }
  ];

  res.dispatch( state => {
    state.set( 'tasks', Immutable.fromJS( tasks ) );

    res.completed()
  });
});

Anonymous Actions

res.dispatch( state => {
  state.set( 'status', 'completed' );
});

Named Actions

engine.register( 'status:update', ( state, params ) => {
  state.set( 'status', params.status );
});

res.dispatch( 'status:update', { status: 'completed' });

Express (Server)

import Immutable from 'immutable';
import { Observable } from 'rx/dist/rx.all';

import express from 'express';

import Engine from 'apostate/engine';
import Router from 'apostate/router';
import ExpressAdapter from 'apostate/adapters/express';

const app = express();

function initialize( req ) {
  const state = Immutable.fromJS({
    // ...
  });

  return Observable.return( state );
}

function render( state ) {
  const content		= React.renderToString( React.createElement( App, { state } ) );
	const document	= React.renderToStaticMarkup( React.createElement( Document, { content, state }) );

	const status = state.get( 'status', 200 );

	return { status, document };
}

const actions = {
  'feed:load': function( state, { done }) {
    done();
  }
}

const router = Router({ adapter: ExpressAdapter({ app, Engine, initialize, render, config: { actions } }) });

router.get( '/', ( req, res ) => {
  const { dispatch } = res;

  const href = ( typeof location != 'undefined' ) ? location.href : '/';
  const network = req.state.getIn( ['session', 'user'] ) ? 'personal' : 'featured';

  dispatch( state => {
    state.delete( 'overlay' );
    state.set( 'page', Immutable.fromJS({ base: 'home', title: "Home | This.", filters: { network } }) );

    res.completed()
  });

  dispatch( 'feed:load', { network, done: res.completed });
});