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

stupid-subscribe

v0.2.1

Published

a stupid subscription utility

Downloads

4

Readme

stupid-subscribe

Tiny JS snippet for an extremely simple, extremely stupid data subscriber.

###API API consists of 2 stupid functions subscribe and action;

action: (fn) => (fn) wraps a function and introduces the sole side effect of triggering all subscribed actions.

subscribe: (listenerFn, readFn) subscribes listenerFn to all actions.

Whenever a function wrapped with action is called, all subscribed listeners are called with the results of their read function, i.e. listenerFn(readFn()) is called

Brief pseudocoded example:

This implements an <h1> that increments a counter when you click on it.

// index.jsx
import {subscribe} from 'stupidsubscribe';
import appInterface from './app.js';
import AppView from './appview.jsx';

subscribe(
  (appProps) => {
    render(<AppView {...appProps} />);
  },
  app.getProps
);
// app.js
import {action} from 'stupidsubscribe';

let numTimes = 0;

export default {
  getProps: () => ({
    text: `Clicked ${numTimes} times`,
    clickHeader: action(() => (numTimes++)),
  }),
};
// index.jsx
const AppView = (props) => (
  <article>
    <h1 onClick={props.clickHeader}>Click Here!</h1>
    {props.text}!
  </article>
);

export default AppView;

###Motivation something something left-pad

Contributing

There's almost certainly no reason to contribute.

FAQ

Does the API even deserve to be called an API? It's not really an interface, as much as it is ~6 lines of utility functions

@evinism

No, probably not, but I went to a hackathon once and the speaker said "API" a lot and I guess it stuck with me.

Can't we modify it so that actions trigger certain subscriptions, rather than all subscriptions, always?

@evinism

I don't want to rename the repo to SlightlyLessStupidSubscribe.

Could I use this on something that's not stupid?

@evinism

Yes, I strongly encourage it. It falls directly in line with a quintessential software design principle of which I am a big proponent, namely:

Software should be an absolute trainwreck

Isn't this a dumbed down version of [x]?

@evinism

Yes, in the same way that everyone is a dumbed down version of Einstein, so too is this a dumbed down version of literally everything.