Thursday, February 26th, 2009

Namespace.js: take a wild guess….

Category: JavaScript, Library

Let’s lead with code:

javascript

  1. Namespace('foo.bar');
  2. foo.bar.myFunction = function() {};
  3.  
  4. Namespace('com.example', {
  5.    MyClass: function() { return {}; }
  6. });
  7. var obj = new com.example.MyClass();
  8.  
  9. Namespace.use('com.example.MyClass');
  10. var obj2 = new MyClass();
  11.  
  12. // include com/example/RemoteClass.js
  13. Namespace.include('com.example.RemoteClass');
  14. var obj3 = new com.example.RemoteClass();
  15.  
  16. Namespace.registerNativeExtensions();
  17. 'com.foo.bar'.namespace();

Reading the code above is probably all you need to know about the new, library independant, JavaScript library Namespace.js, created by Maxime Bouroumeau-Fuseau.

The goals for the library are:

  • Simple API
  • Framework independent
  • Remote file loading (synchronously or async)
  • Tested against Firefox 3.x, Safari 3.x, IE 6/7 and Opera 9.5
  • Highly configurable
  • Events
  • Optionally add methods to native objects

You can see more in the How To.

Posted by Dion Almaer at 2:10 pm
Comment here

+++--
3.2 rating from 29 votes

Comments Here »

Comments feed TrackBack URI

Leave a comment

You must be logged in to post a comment.