This project is archived and is in readonly mode.

#885 ✓invalid
kentaromiura

Function.prototype.protect and any kind of delay - EG. Function.delay

Reported by kentaromiura | April 19th, 2010 @ 09:15 AM

I discovered that calling any protected method with any kind of delay is not possible, it will always throw the
'The method "' + key + '" cannot be called.' Error.

passing the binding parameter, or using .bind doesn't solve anything.

I have to use a very ugly hack to let me call the method, setting the "protected" flag to false before calling delay,
this is obviously incorrect since it doesn't check anymore for method protection.


Function.implement('delay$',function(milliseconds, bind, args) {
(function(){
   if(this._origin && this._origin._protected){                 
       mod = true;
       this._origin._protected = false;
   }
   this.run(args, bind);
   if(mod){
      this._origin._protected = true;
   }    
}).delay(milliseconds, this);
});

This, at least, let me using .protect() on classes where I need to call a method with a delay but I wish I could have a way to check for protection.

Comments and changes to this ticket

  • Christoph Pojer

    Christoph Pojer April 28th, 2010 @ 05:07 PM

    • State changed from “new” to “invalid”

    This is because calling a method with a delay means, in the terms of how we implemented it and in the terms of how JavaScript works, to call it from the outside. You can fix this by calling your protected method inside of the class which then delays a call to an anonymous function hidden in that protected method.

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

Shared Ticket Bins

People watching this ticket

Pages