Wrapping a global JS variable in a JSObjectProxy

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

Wrapping a global JS variable in a JSObjectProxy

Andy Burnett
I am still playing around with Firebase, and I wanted to make all of the Firebase object's methods part of the Amber class browser.  In essence, I was trying to create a Firebase class, and have remove, push, setPriority etc., just appear as methods.

After mucking around for a while, and getting hopelessly lost, it suddenly dawned on me that I probably needed to wrap the Firebase variable inside a JSObjectProxy, and then - maybe? - subclass that object, and include all my method definitions from there.

Has anyone done something like this, i.e. wrap a library, but include the methods in Amber? If so, how did you tackle it?

Cheers
Andy

--
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/groups/opt_out.
 
 
Reply | Threaded
Open this post in threaded view
|

Re: Wrapping a global JS variable in a JSObjectProxy

laci
I've created a wrapper around Knockout. You can find the source at the following link:
http://forum.world.st/using-knockout-js-from-amber-tt4664105.html#a4664214

Hope that helps you.
Reply | Threaded
Open this post in threaded view
|

Re: Wrapping a global JS variable in a JSObjectProxy

Herby Vojčík
In reply to this post by Andy Burnett
running JS

smalltalk.wrapClass(....)

with right arguments (inspired by bottom of boot.js) followed by

smalltalk.init(the-new-class)
(alternatively in Smalltalk via ClassBuilder new setupClass: aClass)

should do the trick.

Andy Burnett wrote:

> I am still playing around with Firebase, and I wanted to make all of
> the Firebase object's methods part of the Amber class browser.  In
> essence, I was trying to create a Firebase class, and have remove,
> push, setPriority etc., just appear as methods.
>
> After mucking around for a while, and getting hopelessly lost, it
> suddenly dawned on me that I probably needed to wrap the Firebase
> variable inside a JSObjectProxy, and then - maybe? - subclass that
> object, and include all my method definitions from there.
>
> Has anyone done something like this, i.e. wrap a library, but include
> the methods in Amber? If so, how did you tackle it?
>
> Cheers
> Andy
>
> --
> You received this message because you are subscribed t
o 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/groups/opt_out.
>
>

--
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/groups/opt_out.


Reply | Threaded
Open this post in threaded view
|

Re: Wrapping a global JS variable in a JSObjectProxy

Andy Burnett
Thank yuou to you both. I shall go and experiment!

By the way, Herby if I can get this to work, it would be good to look at integrating Firebase with Trapped. Adding a simple persistence layer would be very cool.

Cheers
Andy


On Wed, Jul 10, 2013 at 6:05 AM, Herby Vojčík <[hidden email]> wrote:
running JS

smalltalk.wrapClass(....)

with right arguments (inspired by bottom of boot.js) followed by

smalltalk.init(the-new-class)
(alternatively in Smalltalk via ClassBuilder new setupClass: aClass)

should do the trick.

Andy Burnett wrote:
I am still playing around with Firebase, and I wanted to make all of the Firebase object's methods part of the Amber class browser.  In essence, I was trying to create a Firebase class, and have remove, push, setPriority etc., just appear as methods.

After mucking around for a while, and getting hopelessly lost, it suddenly dawned on me that I probably needed to wrap the Firebase variable inside a JSObjectProxy, and then - maybe? - subclass that object, and include all my method definitions from there.

Has anyone done something like this, i.e. wrap a library, but include the methods in Amber? If so, how did you tackle it?

Cheers
Andy

--
You received this message because you are subscribed t
o 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/groups/opt_out.



--
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/groups/opt_out.



--
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/groups/opt_out.