Uploaded image for project: 'Titanium SDK/CLI'
  1. Titanium SDK/CLI
  2. TIMOB-13338

Ti API: implement features to add several listeners to a proxy in one call


    • Type: New Feature
    • Status: Open
    • Priority: Low
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: TiAPI
    • Environment:

      Titanium API


      for example, it would be nice to have a method like Titanium.Proxy.addEventListeners( { } );

      var self = Ti.UI.createWindow({
      	 blur : function(e) { Ti.API.warn( JSON.stringify (e) ) } ,
      	focus: function(e) { Ti.API.warn( JSON.stringify (e)) },
      	myEvent : function(e) { Ti.API.warn(  JSON.stringify (e)) },

      to be clear I know, this can be done in Javascript ( but this means adding a method to Titanium.Proxy ) , and the idea here is not to call addEventListener in a loop but rather cross the bridge only once receiving a NSDictionary to transform callbacks in KrollCallbacks ( something like applyProperties()).

      for IOS my first try was to do :

          ENSURE_SINGLE_ARG(args, NSDictionary);
          for (NSString * currentKey in args)
              KrollCallback*  currentListener = [args objectForKey:currentKey];
              [self addEventListener: [NSArray arrayWithObjects:currentKey, currentListener, nil] ];

      This seems to work, but i'm safe to do that ?

      -Moreover would it be possible to pass a Dictionary of eventListeners in the Ti factory methods ?

      propertyX : value
      eventListeners : { .... } // is this possible for UI events ? custom events ? 

      In some case , this could ensure that the listeners are registered before the events occur ( Ti.UI.Window events for example )

      • I saw that Alloy implement the on(..) off(..) method with event listeners, so another solution could be to use the same syntax in the Proxy create method:

        propertyX : value
        onClick = function(){}


          Issue Links



              • Assignee:
                vince Vincent
              • Watchers:
                4 Start watching this issue


                • Created:

                  Backbone Issue Sync

                  • Backbone Issue Sync is enabled for your project, but we do not have any synchronization info for this issue.

                    Git Integration