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

@rwth-acis/iwc

v1.0.0

Published

This contains JS libraries for interwidget communication and las2peer connectivity.

Downloads

3

Readme

InterwidgetCommunication

This repository contains JS libraries for interwidget communication and las2peer connectivity. The description below shows usage as in the CAE.

Usage

For a full example, take a look at the example ROLE widgets in this repository. Add iwc.js and las2peerWidgetLibrary.js after y.js and jQuery and before your own scripts.

<!-- import jQuery for AJAX calls -->
  <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
  <!-- additional widget specific imports (put your own imports here as well) -->
  <script src=".../bower_components/yjs/y.js"></script>
  <!-- inter widget communication library import -->
  <script type="text/javascript" src=".../js/lib/iwc.js"></script>
  <!-- import the client library -->
  <script type="text/javascript" src=".../js/lib/las2peerWidgetLibrary.js"></script>
  <!-- import application script -->
  <script type="text/javascript" src=".../js/applicationScript.js"></script>

General preparations

Set up y-js, a map named "intents" is neccessary.

Y({
  db: {
    ...
  },
  connector: {
    ...
  },
  sourceDir: ... ,
  share: {
    intents: 'Map'
  }
}).then(function (y) {
  initClient(y);
})

Initialise the iwc client:

...
var initClient = function(y) {
  this.client = new Las2peerWidgetLibrary("", iwcCallback, "http://127.0.0.1:8073", y);
  console.log("Client initialized");
};
...

If you want to react to messages, you have to define a callback function:

...
var iwcCallback = function (intent) {
  // define your reactions on incoming iwc events here 
};
...

Sending messages

You have to decide on an address for messaging. In the examples we use the title of ROLE widgets. An example of sending the content of a textArea locally by using the title of the widget as the address ...

...
var content = document.getElementById('textArea').value;
// Get widget title
var sender = $("head").find("title")[0].text;
//Send locally to widget with title "ReceiveWidget"
client.sendIntent(sender, "ReceiveWidget", "update", content, false);
...

or globally ...

client.sendIntent(sender, "ReceiveWidget", "update", content, true);

Receiving messages

Initialise the client. For global messaging, you have to set up y-js in the same way. Then define your callback and execute further actions, e.g. like this:

var iwcCallback = function (intent) {
  // define your reactions on incoming iwc events here 
  if (intent.action == "update" && intent.receiver == $("head").find("title")[0].text) {
    updateContent(intent.data);
  }
};

var updateContent = function (data) {
  var content = document.getElementById('textArea').value = data;
};

Check the action you want to process and that you set during sending, as well as the address you decided on.

That's it! There is (currently) no difference in receiving local or global intents, as they are unpacked and pre-processed by the library.