Titanium Community Questions & Answer Archive

We felt that 6+ years of knowledge should not die so this is the Titanium Community Questions & Answer Archive

Include Once or Import

Hello!
Is there an import (C style) or include_once (PHP style) statement for mobile?

I tend to use include files that appear to get 'included' more than once which presumably takes a performance hit.

There doesn't appear to be one documented but I'd love to see it. Anyone else?

— asked April 8th 2010 by Charlie Irish
  • import
  • include
  • iphone
  • mobile
  • performance
2 Comments
  • I want this

    — commented February 10th 2011 by Ian Cox
  • I need this too. If you are implementing your own NavBar, then by using include to go to new windows and go back to old ones, you keep piling up the stack. How to make it include once and just call the included windows?

    — commented February 14th 2011 by Bernardo Oliveira

4 Answers

  • This is the standard include statement. I'm looking for an include "once" to stop the file getting included multiple times if it's called multiple times.
    http://developer.appcelerator.com/apidoc/mobile/1.2/Titanium.include.html
    Thanks
    Charlie

    — answered April 9th 2010 by Charlie Irish
    permalink
    0 Comments
  • Ti.include('yourfile.js')

    — answered April 9th 2010 by salo corgan
    permalink
    0 Comments
  • Any update on this to inlcude a file once?

    — answered July 19th 2012 by Rebin Joseph
    permalink
    0 Comments
  • I guess you would need to make your own function include_once() which you would always call instead of include() - and that function would keep a list previously included files, and if the current file asking to be included is already in the list, then skip the include() statement…

    — answered November 13th 2013 by Allan Jensen
    permalink
    0 Comments
The ownership of individual contributions to this community generated content is retained by the authors of their contributions.
All trademarks remain the property of the respective owner.