Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-1007] Android: Proxy object's methods don't have apply/call methods

GitHub Issuen/a
TypeBug
PriorityLow
StatusClosed
ResolutionInvalid
Resolution Date2017-06-12T18:32:42.000+0000
Affected Version/sRelease 3.0.0
Fix Version/sn/a
ComponentsAndroid
Labelscore
ReporterKonstantin
AssigneeIngo Muschenetz
Created2011-04-15T02:41:23.000+0000
Updated2017-06-12T18:32:42.000+0000

Description

All object's methods, like ViewProxy methods, DatabaseProxy methods don't have call/apply methods, I mean apply/call methods of JS Function object, it makes impossible to create wrapper around, for example, Titanium.Database.execute method, which accepts variable number of arguments. IMHO it's a very big limitation not described in documentation and creates a lot of troubles to developers.

Comments

  1. Ernesto 2011-04-15

    I agree, this is a huge limitation as it isn't noted in the docs and the error thrown is cryptic; custom components are also significantly more difficult to develop, e.g.:
       var MyCustomPicker = function(options) {
         this.picker = Ti.UI.createPicker(options.picker);
         this.cancelButton = Ti.UI.createButton(options.cancelButton);
         
         /*
          here's the problem, this makes the app to closes with the following message:
          [DEBUG] Session did end with error (null) 
          */
         this.cancelButton.addEventListener(
           'click', 
           options.onCancel.apply(this, ['any', 'other', 'possible', 'argument']
         );
         
       };
       
       var myPicker = new MyCustomPicker({
         onCancel: function() {
           Ti.API.info(arguments);
         }
       });
       
  2. Damien Elmes 2011-04-15

    A workaround for this was posted in the forums:
       if (typeof db.execute.apply !== 'function') {
           db.execute.apply = Function.prototype.apply;
       }
       
  3. Lee Morris 2017-06-12

    Closing ticket due to the time passed and lack of progress since the opening of the ticket. Any problems, please file a new ticket.

JSON Source