Tibco PageBus: an event framework for JavaScript

Event frameworks are all the rage these days. Sending messages and receiving messages is the preferred way to keep your code separated and loosely coupled, which, as we all know, is the single most important development best practice on the planet.

Flash content has always had a fairly good built in message handling mechanism. The event dispatcher has been around for a while now and served developers well. It's featured prominently in the Flex framework as the foundation for data binding.

But what if you're a developer working in JavaScript? Until recently you were forced to build your own solution or suffer the pain of tightly coupling your components. Into the gap comes Tibco PageBus, an event framework for JavaScript that brings loosely-coupled goodness to the masses.

PageBus is pretty easy to use, providing a few simple methods to wrire your components together. The core it relies on dispatching a message, like this:

function publishValue(s) {
window.PageBus.publish('com.tibco.pagebus.ex.text.select', { text: s});
}

where 's' is the content of the message and 'com.tibco.pagebus.ex.text.select' is the event identifier; and subscribing for those messages, like this:

window.PageBus.subscribe('com.tibco.pagebus.ex.text.select', this, onMessage, null);

where 'this' is the object to receive the event and 'onMessage' is the method to call when it's received. Pretty darn simple, really.

I recently built a short demo that wires an HTML component to a Flash button through PageBus. Click here to see it in action, or here to download the full source.

It was relatively easy to use once I had the kinks worked out of my never-stellar JavaScripting skills, and I was excited to see how modular I could make RIAs. Stop arguing about AJAX vs. Flash - use an event backbone like PageBus and use components from any RIA technology.

About this Entry

This page contains a single entry by RJ Owen published on July 1, 2009 1:02 PM.

Deep Linking Test was the previous entry in this blog.

Introduction to Adobe Flash Collaborative Services is the next entry in this blog.

Find content using the provided navigation or look in the archives to find all content.

Authors

Archives

This content archive is licensed under a Creative Commons License.