How to call Amber method from JS

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

How to call Amber method from JS

horrido
According to "From smalltalk to javascript and back", if I want to call method 'doNextTrack' in 'Myapp', I can do this:

require("amber/helpers").globals.Myapp._doNextTrack();

Just like in the loader where you do this:

amber.globals.Myapp._start();

But it's not working for me. I know 'start' is a class-side method, but that shouldn't matter, right? So what am I doing wrong?

--
You received this message because you are subscribed to the Google Groups "amber-lang" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: How to call Amber method from JS

Herby Vojčík


Richard Eng wrote:

> According to "From smalltalk to javascript and back", if I want to
> call method 'doNextTrack' in 'Myapp', I can do this:
>
> ||
> require("amber/helpers").globals.Myapp._doNextTrack();
>
> Just like in the loader where you do this:
>
> ||
> amber.globals.Myapp._start();
>
> But it's not working for me. I know 'start' is a class-side method,
> but that shouldn't matter, right? So what am I doing wrong?

Why do you think that shouldn't matter?

In fact, nothing matters more.

--
You received this message because you are subscribed to the Google Groups "amber-lang" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: How to call Amber method from JS

horrido
I gather, then, that 'amber.globals.Myapp' is referring to the class, so _start() can be invoked. And _doNextTrack() must be invoked from the instance of Myapp. Is that correct?

Where can I find the Myapp instance?


On Friday, 24 July 2015 05:51:31 UTC-4, Herby wrote:


Richard Eng wrote:

> According to "From smalltalk to javascript and back", if I want to
> call method 'doNextTrack' in 'Myapp', I can do this:
>
> ||
> require("amber/helpers").globals.Myapp._doNextTrack();
>
> Just like in the loader where you do this:
>
> ||
> amber.globals.Myapp._start();
>
> But it's not working for me. I know 'start' is a class-side method,
> but that shouldn't matter, right? So what am I doing wrong?

Why do you think that shouldn't matter?

In fact, nothing matters more.

--
You received this message because you are subscribed to the Google Groups "amber-lang" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: How to call Amber method from JS

Herby Vojčík


Richard Eng wrote:
> I gather, then, that 'amber.globals.Myapp' is referring to the class, so
> _start() can be invoked. And _doNextTrack() must be invoked from the
> /instance/ of Myapp. Is that correct?
>
> Where can I find the Myapp instance?

Nowhere, unless you store it somewhere.

I think the need to do this shows some design problem. See augmentPage
method in pristine project - it sets up callbacks that need to do things
for a Myapp instance without actual need to publish it. I think the call
to doNextTrack is also needed more-or-less as a reaction to some event
(broad meaning of a word), which should be also done by Smalltalk
installing the callback itself to appropriate place (not trying to get
in from JS side). Ideally, the Myapp._start() call should be only use of
globals and the pieces of an app can then talk to each other (import
vars FTW).

> On Friday, 24 July 2015 05:51:31 UTC-4, Herby wrote:
>
>
>
>     Richard Eng wrote:
>      > According to "From smalltalk to javascript and back", if I want to
>      > call method 'doNextTrack' in 'Myapp', I can do this:
>      >
>      > ||
>      > require("amber/helpers").globals.Myapp._doNextTrack();
>      >
>      > Just like in the loader where you do this:
>      >
>      > ||
>      > amber.globals.Myapp._start();
>      >
>      > But it's not working for me. I know 'start' is a class-side method,
>      > but that shouldn't matter, right? So what am I doing wrong?
>
>     Why do you think that shouldn't matter?
>
>     In fact, nothing matters more.
>
> --
> You received this message because you are subscribed to the Google
> Groups "amber-lang" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to [hidden email]
> <mailto:[hidden email]>.
> For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "amber-lang" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: How to call Amber method from JS

horrido
Okay, thanks. These are wise words.


On Friday, 24 July 2015 09:10:30 UTC-4, Herby wrote:


Richard Eng wrote:
> I gather, then, that 'amber.globals.Myapp' is referring to the class, so
> _start() can be invoked. And _doNextTrack() must be invoked from the
> /instance/ of Myapp. Is that correct?
>
> Where can I find the Myapp instance?

Nowhere, unless you store it somewhere.

I think the need to do this shows some design problem. See augmentPage
method in pristine project - it sets up callbacks that need to do things
for a Myapp instance without actual need to publish it. I think the call
to doNextTrack is also needed more-or-less as a reaction to some event
(broad meaning of a word), which should be also done by Smalltalk
installing the callback itself to appropriate place (not trying to get
in from JS side). Ideally, the Myapp._start() call should be only use of
globals and the pieces of an app can then talk to each other (import
vars FTW).

> On Friday, 24 July 2015 05:51:31 UTC-4, Herby wrote:
>
>
>
>     Richard Eng wrote:
>      > According to "From smalltalk to javascript and back", if I want to
>      > call method 'doNextTrack' in 'Myapp', I can do this:
>      >
>      > ||
>      > require("amber/helpers").globals.Myapp._doNextTrack();
>      >
>      > Just like in the loader where you do this:
>      >
>      > ||
>      > amber.globals.Myapp._start();
>      >
>      > But it's not working for me. I know 'start' is a class-side method,
>      > but that shouldn't matter, right? So what am I doing wrong?
>
>     Why do you think that shouldn't matter?
>
>     In fact, nothing matters more.
>
> --
> You received this message because you are subscribed to the Google
> Groups "amber-lang" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to <a href="javascript:" target="_blank" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">amber-lang+...@...
> <mailto:<a href="javascript:" target="_blank" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">amber-lang+unsubscribe@...>.
> For more options, visit <a href="https://groups.google.com/d/optout" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;">https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "amber-lang" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.