Ah ic. I was just using Worker as an example. But good to know.

On Sep 10, 2:00 pm, "waldron.r...@gmail.com" <waldron.r...@gmail.com>
wrote:
> additionally.... i would NOT call your function "Worker" in the global space. 
> google "javascript web workers" and you'll see why...
>
>
>
> -----Original Message-----
> Date: Thursday, September 10, 2009 2:46:16 pm
> To: "Prototype & script.aculo.us" <prototype-scriptaculous@googlegroups.com>
> From: "Ngan" <nganp...@gmail.com>
> Subject: [Proto-Scripty] Re: Private methods for prototype class
>
> Hi Allen, thank you so much for the reply.
>
> If I do it that way, someVar will now be a private variable.  What if
> I wanted someVar to be an instance variable.  so that it may be
> accessed externally:
>
> aWorker.someVar
>
> hence why I did:
>
> this.someVar = 'var';
>
> Is this something that you have to give up when going with this
> pattern?
>
> On Sep 10, 11:07 am, Allen <bla...@gmail.com> wrote:
> > Hi Ngan,
>
> > This should do what you want.
>
> > var Worker = Class.create((function() {
> >  var someVar;
> >  function initialize() {
> >    someVar = "var";
> >    privateMethod();
> >  }
> >  function publicMethod() {
> >    privateMethod();
> >  }
> >  function privateMethod() {
> >    console.info(someVar);
> >    console.info(this)
> >  }
> >  return {
> >   initialize: initialize,
> >   publicMethod: publicMethod
> >  };
>
> > })());
>
> > On Sep 10, 1:10 pm, Ngan <nganp...@gmail.com> wrote:
>
> > > Hi, I apologize if this question has been asked before. I've tried
> > > googling for this, but did find a good ans
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Prototype & script.aculo.us" group.
To post to this group, send email to prototype-scriptaculous@googlegroups.com
To unsubscribe from this group, send email to 
prototype-scriptaculous+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to