Widget support added to easyXDM!

The newest version of easyXDM (v1.5.3) now includes two new classes, the easyXDM.WidgetManager, and easyXDM.Widget.

These make it extremely easy to make mashups based on the subscribe/publish architecture.

To read more about easyXDM check out this blog post.

The widget demo can be found at http://consumer.easyxdm.net/current/example/widgets.html,  and if you want to, just copy the code for the widget found here, modify the src for the scripts and save it to your own domain – you should now be able to add it from the WidgetManager!

The WidgetManager

To set up a page to contain widgets we need an instance of the WidgetManager:

var _widgetManager = new easyXDM.WidgetManager({
    local: "../hash.html",
    container: document.getElementById("widgets")

And with the widgetmanager set up we continue by adding widgets by their url


And thats it 🙂

The widgets

Creating a widget isn’t much more work

The following is a skeleton widget

var widget = new easyXDM.Widget({
    subscriptions: ["testtopic"],
    initialize: function(widget, widgetManager){
        // Set up the widget

        // Render the UI

        // Register the handler for incoming messages
        widget.registerMessageHandler(function(url, topic, data){
            // Do something
    initialized: function(widget, widgetManager){
        //This is called after the widget has been initialized by the widgetmanager

To create a custom widget you only need to select the internet slots canada topics to subscribe to, build the UI, and handle the incoming messages the way you see fit.

To publish your own messages you simply use widget.publish  like this

widget.publish("position", {
    latitude: "60.378776",
    longitude: "5.337811"

and all subscribers will get this.

It’s that easy!

Tags: , ,

This entry was posted on Sunday, September 6th, 2009 at 16:37 and is filed under easyXDM, programming. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

  • Anonymous

    Are these examples still valid? The demo links are broken 🙁

    • Still valid (and link has been updated), but the Widget framework is really just a proof-of-concept of how one could build such a thing around easyXDM – it’s really not meant for productions usage 🙂