New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

rukus-signal

Package Overview
Dependencies
Maintainers
5
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rukus-signal

Signal management for rukus apps, built with riot.Observable

  • 1.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
5
Created
Source

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.

Keywords

FAQs

Package last updated on 28 Dec 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc