Gmail Calendar Documents Reader Web more »
Recently Visited Groups | Help | Sign in
Google Groups Home
Adding a object data to PeriodicalExecuter
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  3 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
superruzafa  
View profile  
 More options Jun 22, 12:45 pm
From: superruzafa <superruz...@gmail.com>
Date: Mon, 22 Jun 2009 09:45:28 -0700 (PDT)
Local: Mon, Jun 22 2009 12:45 pm
Subject: Adding a object data to PeriodicalExecuter
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?


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
superruzafa  
View profile  
 More options Jun 23, 10:18 am
From: superruzafa <superruz...@gmail.com>
Date: Tue, 23 Jun 2009 07:18:20 -0700 (PDT)
Local: Tues, Jun 23 2009 10:18 am
Subject: Re: Adding a object data to PeriodicalExecuter
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:


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Yaffle  
View profile  
 More options Jun 23, 10:25 am
From: Yaffle <vic99...@yandex.ru>
Date: Tue, 23 Jun 2009 07:25:46 -0700 (PDT)
Local: Tues, Jun 23 2009 10:25 am
Subject: Re: Adding a object data to PeriodicalExecuter
Why you can't use closure or Function#curry based on it?

(new PeriodicalExecuter(function(someData){
  var x = someData.num;
  // ....


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2009 Google