Titanium JIRA Archive
Alloy (ALOY)

[ALOY-111] Create simple sample that shows application life cycle

GitHub Issuen/a
TypeStory
PriorityMedium
StatusClosed
ResolutionDuplicate
Resolution Date2012-08-10T11:08:23.000+0000
Affected Version/sn/a
Fix Version/sn/a
ComponentsRuntime
Labelsn/a
ReporterRussell McMahon
AssigneeTony Lukasavage
Created2012-07-18T09:24:46.000+0000
Updated2014-02-04T00:34:52.000+0000

Description

Comments

  1. Tony Lukasavage 2012-07-18

    Do you mean lifecycle events? Right now I only created 'onCreate' for the generated components, which is attached via markup like this:

    index.xml

       <Alloy onCreate="doCreate">
           <!-- the rest of your elements -->
       </Alloy>
       

    index.js

       function doCreate() {
           // insert code to be executed before generated view and controller code
       }
       
  2. Russell McMahon 2012-07-18

    Yup. Looks good but I think we should also have a matching destroy. Are there other App life cycle events we could make available through markup?
  3. Tony Lukasavage 2012-07-18

    Well, we can have a destroy life cycle event, but it would need to be fired manually so I don't know how much sense it makes. I think it might confuse developers if we allow them to specify an onDestroy function, but the event never fires unless they fire/trigger it manually. On the other hand, having a standardized location even for manually triggered destroy operations would be good. I'm not sure how we can be clear that an onCreate happens automatically, but an onDestroy needs to be done manually.
  4. Russell McMahon 2012-07-18

    Can we generate the code to fire an app destroy event so the developer does not manually have to do it?
  5. Tony Lukasavage 2012-07-18

    No, that's the nature of Javascript and why it's been done manually to this point.
  6. Russell McMahon 2012-07-18

    Not sure if this would work but found it online: Ti.App.addEventListener('pause',function(e) { // do code here }); http://developer.appcelerator.com/question/139716/is-there-any-way-i-can-respond-to-the-application-close-event
  7. Russell McMahon 2012-07-18

    I see the pause is an iOS only event so not as helpful
  8. Tony Lukasavage 2012-07-18

    The app in that case can just as easily resume, and you would have destroyed all of its components. Obviously not the desired effect. This makes the case for onPause and onResume events, but we don't have an object to apply them to, as they would apply to the application, not a specific component. It would probably make more sense right now to just handle them as they are now.
  9. Tony Lukasavage 2012-08-10

    duplicate of ALOY-165

JSON Source