My Opera is closing 1st of March

Covert Tomato

Spending CPU cycles associating random words

PSO, Yusef and Unite

, , ,

I spent the last few days building a new application for Unite. So I read all the nice articles, downloaded the full hello world , and found myself stuck with more questions than answers. Maybe I missed some documentation, but for sure the libraries in the example app offer a helluva lot features. I plan to go over some of these libs in the next few post; hopefully, some official documentation/articles will get available soon. Generally speaking, while this may seem a bit rough for a first post, I plan to use this blog as a way of writing memos about technical stuffs; I'm not too sure about blogging, but since everyone else (and their dog) do so...

Anyway, let me get started by pointing out the PSO lib, used for debugging purposes. This lib acts as a wrapper around opera.postError, which gets error messages straight to the error console. PSO messages are required to have an ID, which is a string identifying the message origin or category.

One can subscribe to messages of interest by specifying IDs:
PSO.sub(id1, id2, ...)

where id1, id2 are the ids. This effectively filters messages out, when no subscription has been made.

Debug messages are published using:
PSO.pub(id, msg)

where id is the message ID, and message is the actual debug information.

Subscribing to the special 'new pub' id, one can subscribe to get a list of new message ids. Other predefined ids in use throughout Yusef can be found at the beginning of yusef/core.js, right under switch( opera.io.webserver.userName ). Some of these are useful when debugging/adding new features to Yusef, while others can tell you important information about why your code fail. Did you register your section properly? Subscribe to 'Yusef.addSectionListener' to know. Which section is requested when you click that link? Subscribe to 'yusef request handle'.

I personally found it useful to express ids as a hierachy (e.g 'fpicalausa.myapp.feature42'), in order to keep code clean component-wise. Going along with this convention, I also modified PSO (see attachment at the end), so that it allows me to subscribe to messages higher in the hierarchy (e.g. 'fpicalaua.myapp' to get all messages in myapp).

Enjoy!

pso.js

yusef .ui and filter for markuper

Comments

Mathieu 'p01' HENRIp01 Monday, January 11, 2010 3:44:52 PM

The PSO library comes in very handy when several developers work on the same application. That way it's possible for each and everyone to declare which message they want to subscribe to in an if( opera.io.webserver.userName===myName ){ PSO.sub( theThingsIAmWorkingOnAtTheMoment ); } without polluting everybody' error console.

Write a comment

New comments have been disabled for this post.