[ALOY-295] Need bootstrap hooks in the app

GitHub Issuen/a
TypeNew Feature
Resolution Date2012-10-01T21:01:17.000+0000
Affected Version/s2012 Sprint 19
Fix Version/s2012 Sprint 20, Release 3.0.0
ComponentsRuntime, XML
ReporterRick Blalock


There needs to be a way to have events or hooks in to the app lifecycle. Here's a scenario: Currently Alloy.isTablet applies to anything from 7" and above. A common scenario for app developers is a 7" tablet should use the handheld layout. So I need to override Alloy.isTablet to only apply to tablets larger than 7". Currently there is no way for me to modify this in Alloy. The only way I can think of these types of overrides working is to allow us to change things in the Alloy module and others inside the bootstrap.


  1. Tony Lukasavage 2012-09-24 Seems like an "alloy'js" file at the root of the app directory, which is executed _after_ the main CFG is loaded, but _before_ the index controller is created, would cover 90% of the use cases. It would provide a simple way for developers to execute code in their app before any controllers are loaded, or styles are applied. This would also give you the opportunity to override Alloy.isTablet and Alloy.isHandheld before they are ever used.
  2. Tony Lukasavage 2012-10-01 "app/alloy.js" file contents will be inserted directly into the new app.js template, which now looks like this:
        * Alloy for Titanium by Appcelerator
        * This is generated code, DO NOT MODIFY - changes will be lost!
        * Copyright (c) 2012 by Appcelerator, Inc.
       var Alloy = require('alloy'),
       	_ = require('alloy/underscore')._;
       Alloy.CFG = require('alloy/CFG');
       <%= alloyJs %>

JSON Source