Titanium Community Questions & Answer Archive

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

Feature request regarding file inclusion and context

in short: include file only once in the same context if included more than once.


Ti.include("foo.js", "bar.js");

//in foo.js
Ti.include("needed.js", "needed2.js");

//in bar.js

in this trivial example needed.js included twice, i know that some may suggest to use flat inclusion like

Ti.include("foo.js", "bar.js", "needed.js", "needed2.js");

but this approach isn't good for large projects and alot of dependencies.
every file should include its needed files without caring about if the file included before or not.

— asked November 23rd 2010 by mostafa farghaly
  • include

1 Answer

  • I implemented a simple script loader that loads into the current context exactly once in Helium, my little helper library for Titanium - you could give Helium a try or steal that bit of code - whole impl is 9 LoC.

    — answered November 23rd 2010 by Kevin Whinnery
    1 Comment
    • thank you kevin, i use code similar to yours to manage dependencies. but since the impl. is very trivial it would be convenient if it's Ti built-in, very cool framework btw, it's the first to know about it

      — commented November 23rd 2010 by mostafa farghaly
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.