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

rukus-signal

v1.1.0

Published

Signal management for rukus apps, built with riot.Observable

Downloads

4

Readme

rukus-signal

signalling for rukus apps

Usage:

In your rukus app's index.js, create a signals instance on your App object:

var Signal = require('rukus-signal');
RukusApp.signals = new Signal(RukusApp, riot);

You can then use RukusApp.signals to connect views to things like a store:

A simple todo store which emits an updated signal and accepts a new todo.

function TodoStore() {
    RukusApp.signals.init(this);

    this.todos = [];

    this.emits({   
        signal : 'updated',
        desc : `signaled when the TodoStore has changed, observers should watch
                for this event if they are interested in TodoStore updates.`,
        data : 'null'
        });

    this.accepts({ 
        signal : 'new',
        desc : 'adds a new Todo to the store',
        data : 'A Todo object',
        func : (todo) => {
            this.todos.push(todo);
            this.emit('updated');
        }});
};

RukusApp.todoStore = new TodoStore();

A component which renders and adds todos:

module.exports = function(opts) {
    RukusApp.signals.init(this);

    this.binds({ 'todoStore:updated' : this.update });
    this.invokes({'new' : 'todoStore:new'});

    this.add = () => {
        this.invoke('new', { todo : this.todo.value });
    };
};

API

Signal.init(this)

Initialises an object or component handler to use rukus signals.

Signal.doc() -> JSON

Returns a JSON structure which documents every controller and component which have registered with this rukus singnal instance, and who communicates with who.

this.accepts(sig1, sig2, ...)

Takes one or more signal definitions, stating that this object accepts these signals and acts on them. signal definitions must be in the format:

{ 
    signal : 'signalName',
    desc : `a description of what this signal does.`,
    data : `a description of the data it requires.`,
    func : [Function] // which will be called if this signal is recieved.
}
this.binds(signals)

Takes an object of signal paths to functions and binds them to this object.

A signal path is a string in the format of:

'dotted.path.to.object.under.RukusApp:signalName' 

Eg:

{ 'todoStore:updated', this.update }

In the event that the todoStore signals updated, call this.update.

this.emits(sig1, sig2, ...)

Takes one or more signal definitions, stating that this object emits these signals. signal definitions must be in the format:

{ 
    signal : 'signalName',
    desc : `a description of what this signal means.`,
    data : `a description of the data it sends.`,
}
this.emit(signalName, data)

Emit a signal by name as defined by this.emits. Optionally emit data.

this.invokes(signals)

Takes an object of local name to signal paths on other objects, indicating that this object intends to invoke their signals.

{ 'newTodo' : 'todoStore:updated', ... }

This object may now invoke 'newTodo'.

this.invoke(signalName, data)

Invoke a signal by name, as defined via this.invokes.