Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-16984] TiAPI: Deprecate Ti.include

GitHub Issuen/a
TypeImprovement
PriorityMedium
StatusClosed
ResolutionFixed
Resolution Date2014-06-23T17:18:28.000+0000
Affected Version/sRelease 3.2.3
Fix Version/sRelease 3.3.0
ComponentsTiAPI
Labelsn/a
ReporterMalcolm Hollingsworth
AssigneeIngo Muschenetz
Created2014-05-15T12:36:48.000+0000
Updated2014-08-12T20:22:23.000+0000

Description

The Ti.include method was a solution fit for another time in Titanium's history. That time has long since gone. Too many newbies are using Ti.include as if it is the correct pattern to develop their apps against. The only reason against deprecation is that some older apps still use Ti.include. However using this as a reason only serves to increase the number of apps this will affect.

Comments

  1. Tony Lukasavage 2014-05-15

  2. Ritu Agrawal 2014-05-19

    Moving this ticket to engineering for further evaluation and prioritization. This ticket was originated based on the community discussion around relevance of Ti.include.
  3. Malcolm Hollingsworth 2014-05-19

  4. Ingo Muschenetz 2014-06-28

    [~bhatfield] does anything else need to be done to show this as "deprecated" in Studio warnings?
  5. Eric Merriman 2014-07-08

    "Titanium.include" shows as deprecated in Studio content assist. "Ti.include" does not show any content assist. Both "Ti.include" and "Titanium.include" do not show anything in console during build or app run.
  6. Satyam Sekhri 2014-07-17

    Verified on Titanium SDK: 3.3.0.v20140711123603 AppC Studio: 3.3.0.201407111535 The content assist shows deprecated for both Ti.include and Titanium.include. However, no deprecated message is shown in console when app is build and run on Android or iOS.
  7. Neville Dastur 2014-07-17

    Maybe it is too late. But this depreciation really effects the ability to use third party JS libraries. Of course they can be wrapped, but by depreciating an include mechanism it means the "original" file needs to be edited. At present I can Ti.include a third party JS library into my own commonJS module and then happily write over the third party library when ever updates are released. I am not sure how policing against bad user coding in this one particular instance helps.
  8. Neville Dastur 2014-07-17

    BTW I understand the currently problems with Ti.include but fixing those and making it a true include would be better. Maybe something in alloy that acts more like a c-preprocessor would be the way to go
  9. Chris Barber 2014-08-12

    Ti.include() should have never existed. If you really, really need similar functionality, then consider a workaround like this:
       function include(file) {
           return eval(Ti.Filesystem.getFile(Ti.Filesystem.resourcesDirectory, file).read().text);
       }
       
    I believe that Ti.include() evaluates scripts globally whereas this workaround should only be scoped to your module unless it is run from the app.js.
  10. Neville Dastur 2014-08-12

    Thank you Chris. I completely agree that the included script should not be imported into the global space and this work around does the trick. What I was suggesting was for Ti.include to be fixed to work like this rather than how it did originally
  11. Eric Merriman 2014-08-12

    [~ndastur], I was waiting for dev response to your comment. Since this feature was implemented and validated, we were waiting until the end of the cycle to close. I noticed your comment as I was about to do that. I will close this ticket now, but if you feel there would be benefit from an improvement in this area, please write a new improvement or feature ticket. Thanks, your friendly QE team.

JSON Source