KnockoutJS wrapper for GopherJS

169 views
Skip to first unread message

Michael Bitzi

unread,
May 7, 2015, 8:28:50 AM5/7/15
to goph...@googlegroups.com
Hi,
I made a KnockoutJS wrapper for GopherJS:


There is also a small example of how to create a basic single page application with it.

I started out using GopherJS-Angular for one of my projects. But I quickly realized that GopherJS and AngularJS don't fit well together and is quite cumbersome. Especially if using goroutines or other async calls there were scope.Apply everywhere, which made the code quite messy. Also AngularJS dependency injection doesn't work well with GopherJS.
So I switched to KnockoutJS and everything became much easier and cleaner. Because its just a small library and doesn't make any assumptions about your code its much easier to integrate and work with. Also, with KnockoutJS observables I can now just update my data inside a goroutine / ajax-call / websocket-message, even in another package, and the view updates automagically :)

Richard Musiol

unread,
May 7, 2015, 9:04:58 AM5/7/15
to Michael Bitzi, goph...@googlegroups.com
That's cool! Yeah, I also noticed that AngularJS and GopherJS are not really a good fit. I haven't looked into KnockoutJS yet, but your description sounds promising. I recently used React, which I liked very much, because its spirit is kind of the same as Go. But it also does not fit well with GopherJS. Maybe I'll write a React-inspired Go library at some point.

Cheers,
Richard

--
You received this message because you are subscribed to the Google Groups "GopherJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gopherjs+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Dmitri Shuralyov

unread,
May 7, 2015, 4:39:23 PM5/7/15
to goph...@googlegroups.com, mib...@gmail.com
That description sounds pretty cool! I haven't had a chance to play with it.

There are some other people looking to make React-like library for use with GopherJS too.

Michael, I think you should feel free to add your library/binding to https://github.com/gopherjs/gopherjs/wiki/bindings list if you think it's ready.

Michael Bitzi

unread,
May 7, 2015, 4:53:27 PM5/7/15
to goph...@googlegroups.com
Thanks, I will add it :)

It's not 100% feature complete, but all the important things are in it.
I myself have been using it on a relatively large webapp for a while now, so I am quite confident with it.

A React-like library sounds very interesting! Is there already some development going on for that?

Ben Echols

unread,
May 8, 2015, 11:41:39 AM5/8/15
to goph...@googlegroups.com, mib...@gmail.com
I use quite a bit of React and think that GopherJS could be a good match for it. The flux pattern of asynchronous actions that get passed between stores and components would be really easy to do with Go.

What were you thinking would be problematic?

Ben

Bjørn Erik Pedersen

unread,
Feb 1, 2016, 9:31:49 AM2/1/16
to GopherJS
If someone wants inspiration for a ReactJS integration, have a look at ClojureScript's great OM:

https://github.com/omcljs/om
Reply all
Reply to author
Forward
0 new messages