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

macchiato-eventbus

v0.0.1

Published

Macchiato-eventbus ==================

Downloads

2

Readme

Macchiato-eventbus

Macchiato-eventbus is a distributed event bus written in JavaScript. It allow to distribute applications between your navigator, node.js application server, Java and Android application by using Rhino script engine.

You can use Macchiato-eventbus to build real-time web and mobile applications.

Documentation

Using macchiato-eventbus in your webpage

To use the Macchiato-eventbus, you just have to reference the file from GitHub in the script tag:

<script src="https://rawgithub.com/petitpre/Macchiato-eventbus/master/target/macchiato.min.js"></script>

You can also download a copy of macchiato-eventbus (compressed or uncompressed) and using it locally.

You can find a complete client-side event-bus here.

Using eventbus in your node.js applications

To use macchiato-eventbus in your node.js application, you need to install module macchiato-eventbus

npm install macchiato-eventbus

You can use the bus event macchiato in your node.js application :

require("macchiato-eventbus");

macchiato.createServerApplication(function(bus) {
  // register to hello event
  bus.subscribe(function(msg) {
     console.log("received :" + JSON.stringify(msg));
  }, { hello : ".*" });

  // send a hello event
  bus.publish({ hello : "my name" });
});

Using Event-bus on Android applications

% TODO : create a giter8 template

Prerequisite

You need to have node.js installed on your computer.

We will create an application with two parts. The first is a node.js server, which reads the values ​​from the console and publish an event with content. The second is a web client connected to the server. It will display all messages entered into the server console.

In your project directory, use node package manager to install macchiato event-bus :

npm install macchiato-eventbus

To create the server, put the following code into a file server.js

require("macchiato-eventbus");

macchiato.createServerApplication(function(bus) {
  // read standard input
  var sys = require("sys");
  var stdin = process.openStdin();
  stdin.addListener("data", function(d) {
    bus.publish({"entered" : d.toString().substring(0, d.length - 1) });
  });
}).listen(8080);

To create the client, put the following code into a file index.html

<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Strict//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd'>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr" lang="fr"><head><title>Hello world</title>

<script src="https://rawgithub.com/petitpre/Macchiato-eventbus/master/target/macchiato.js"></script>
<script src="http://code.jquery.com/jquery-1.10.1.min.js"></script>

<script type="text/javascript">
  $(function() {
    macchiato.createEventApplication(function(bus) {
      bus.subscribe(function(msg) {
        $("#content").append(msg.entered + "<br/>");
      }, {'entered' : ".*" });
      bus.createChannel("ws://localhost:8080").when(function() {
        console.log("connected to server !");
      });
    });
  });
</script>
</head><body><div id="content"></div></body></html>

To run example, run server with command node server.js and open index.html in your browser. The text entered in the server console will be displayed in the web page.

Handler references

To send an event to an handler, you can use the handler reference :

// register an handler with a reference
var handlerref = bus.subscribe(function(msg) {
    // my event-handling code
});
	// send message directly to handler
bus.send("my event").to(handlerref);

The references may be useful in some cases, but it is preferable to use content-based filtering presented in the next section.

Content-based subscription

In Macchiato-eventbus, we also provide a content-based filtering. You can specify a constraint when subscribing the handler.

bus.subscribe(function(msg) {
  // your handling code
},
// content filter
 {
  'welcome' : ".*"
});

This handler will match every message with a "welcome" property. The properties of the subscription pattern are defined using JavaScript regular expressions. Each filter properties is tested recursively against property of events.

Creating a channel between two bus

To connect the bus events, we use channels. A channel is always open to the initiative of a client to a server. Typically, the client is your web browser and the server is a server node.js. An event-bus running in node.js can also establish a connection to another node.js event-bus

Event-bus running in web browsers and Android can not accept incoming connections.

Once the event-bus are connected by a channel, the events from each event-bus are automatically routed to matching handlers.

you need to have node.js installed

install node.js dependencies :

$> npm install

Build last version of Macchiato event bus :

$> grunt

Uncompressed and compressed version of macchiato-eventbus are available in target directory

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.