[ALOY-111] Create simple sample that shows application life cycle
GitHub Issue | n/a |
---|---|
Type | Story |
Priority | Medium |
Status | Closed |
Resolution | Duplicate |
Resolution Date | 2012-08-10T11:08:23.000+0000 |
Affected Version/s | n/a |
Fix Version/s | n/a |
Components | Runtime |
Labels | n/a |
Reporter | Russell McMahon |
Assignee | Tony Lukasavage |
Created | 2012-07-18T09:24:46.000+0000 |
Updated | 2014-02-04T00:34:52.000+0000 |
Do you mean lifecycle events? Right now I only created 'onCreate' for the generated components, which is attached via markup like this:
index.xml
index.js
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?
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 anonDestroy
function, but the event never fires unless they fire/trigger it manually. On the other hand, having a standardized location even for manually triggereddestroy
operations would be good. I'm not sure how we can be clear that anonCreate
happens automatically, but anonDestroy
needs to be done manually.Can we generate the code to fire an app destroy event so the developer does not manually have to do it?
No, that's the nature of Javascript and why it's been done manually to this point.
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
I see the pause is an iOS only event so not as helpful
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
andonResume
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.duplicate of ALOY-165