# Fuse.js (0.1.0) Globally Available Objects, Namespaces and Node.js Style EventEmitters for Titanium Mobile. Currently only for iOS. Android Support on the way. ## Usage You MUST require fuse in your app.js so it can be added to the global scope
//Add fuse to global scope require('Fuse').w(this)
## Fuse "w"ith Fuse Objects with Global Scope or fuse namespace Set third param to true if you want to fuse with the Global Scope If false or undefined object will fuse with "fuse" namespace
//Create Object basic object var ui = { view : Ti.UI.createView, label : Ti.UI.createLabel, table : Ti.UI.createTableView, tableRow : Ti.UI.createTableViewRow, window : Ti.UI.createWindow, animation : Ti.UI.createAnimation }; /** * Set third param to true if you want to fuse with the Global Scope * If false or undefined object will fuse with "fuse" Object */ fuse.w('ui', ui, true) .w('console', Ti.API, true) .w('info', Ti.API.info, true) .w('log', Ti.API.log, true) // log('test') .w('log', Ti.API.info) // fuse.log('test') .w('debug', Ti.API.debug, true)
## Creating a "fused" Object and Nesting "fused" Objects All "fused" Objects come equipted with EventEmitters and the ability to nest new children objects; Use the "parent()" function to back out of a "fused" Object
//Create Custom fused Object fuse.create('base', true) .w('test', function(){alert('test Base');} ) //Add function .create('child') //Create Nested Object .w('test', function(){alert('test Child');} ) //Add function to Nested Object .parent() //Back out of Object to Parent .create('sibling') //Create Sibling Object .w('test', function(){alert('test Sibling');} ) //add function to Sibling Object //Function Calls fuse.log('Test'); base.test(); base.child.test(); base.sibling.test();
## EventEmitters Node.js Style EventEmitters
//Adds a listener. fuse.on('event', function(){}); //Emits an event fuse.emit('event', {}); //Adds a volatile listener fuse.once('event', function(){}); //Removes a listener fuse.removeListener('event', function(){}); //Removes all listeners for an event fuse.removeAllListeners('event'); //Gets all listeners for a certain event fuse.listeners('event');
## License (The MIT License) Copyright (c) 2011-2012 Christian Sullivan <[email protected]> Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.














