I used a inherit class to implement that functionality:

var PeriodicalExecuterUserData = Class.create(PeriodicalExecuter,
{
        initialize: function($super, callback, frequency, userdata)
        {
                this.userdata = userdata;
                $super(callback, frequency);
        }
});

then you can use this object calling

new PeriodicalExecuterUserData
(
        function (pe)
        {
                // do something inteligent with pe.userdata;
                pe.userdata.number++
                pe.userdata.string = "string2"
                pe.stop();
        },
        0.1,
        { number: 1, string: "string" }
);




On 22 jun, 18:45, superruzafa <superruz...@gmail.com> wrote:
> Hi, I needed access some object in each iteration of a
> PeriodicalExecuter's function but I didn't want to use global
> variables. So I modified the definition of initialize method of
> PeriodicalExecuter class declaration adding a new parameter "data":
>
> var PeriodicalExecuter = Class.create({
>   initialize: function(callback, frequency, data) {
>     this.callback = callback;
>     this.frequency = frequency;
>     this.currentlyExecuting = false;
>     this.data = data;
> ...
>
> Then I could retrieve this object through the pe parameter of the
> function called every iteration through pe.data. Would be useful to
> implement officially this? There is any reason to don't do it?
>
> Even, I think I could declare a subclass of PeriodicalExecuter like
> PeriodicalExecuterParam or so.
>
> What do you think?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Prototype: Core" group.
To post to this group, send email to prototype-core@googlegroups.com
To unsubscribe from this group, send email to 
prototype-core-unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/prototype-core?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to