Introducing a new plugin: Knockout.live

628 views
Skip to first unread message

Ω Alisson

unread,
Jan 28, 2011, 8:28:09 AM1/28/11
to knock...@googlegroups.com
I'm developing a plugin to ease the pain of synchronising viewstate automatically between multiple clients.

This is totally alpha! :)

https://github.com/thelinuxlich/knockout.live.plugin

Steven Sanderson

unread,
Jan 28, 2011, 9:46:14 AM1/28/11
to knock...@googlegroups.com
That is extremely cool! 

I guess not many applications would want to share live observables across everyone currently connected to your site, but for those that do, your solution is very slick! What might be more common would be having some sort of server-side model (containing KO observables) that are synchronised live with read-only versions of those observables on all the clients. I've never tried running KO on the server (e.g., in Node.js) but it should certainly either work or be possible to make work. For example, you could have a matrix of stock prices on the server that gets updated every few seconds, and each client has corresponding observables for the prices bound to a UI which updates in real-time as the server-side values change.

Very nice how you got websockets to work so simply. Really impressed by this sort of thing.

Steve



2011/1/28 Ω Alisson <thelin...@gmail.com>

Ω Alisson

unread,
Jan 28, 2011, 10:18:34 AM1/28/11
to knock...@googlegroups.com
Thanks Steven, for me it means a lot your reaction, since I've learned a lot from your source code :)
I've tried initially with some sort of JSON representation of the observables, but it ended too complex and it would be slow for large viewModels(also, how could I transport dependentObservables via JSON without stringifying the functions, I think it's ugly to do this). I still need to think about this implementation 'cause it would be a safe way to avoid update conflicts on the observables(maybe a locking mechanism based on timestamp attached to every observable on the server).


2011/1/28 Steven Sanderson <ste...@stevensanderson.com>

Roy Jacobs

unread,
Jan 28, 2011, 11:35:58 AM1/28/11
to knock...@googlegroups.com
Very well done :)

mkidder

unread,
Jan 28, 2011, 1:47:42 PM1/28/11
to KnockoutJS
Now I have an excuse to play with Node.js! :) Just glanced over code,
but looks well written.

Are you actively working on a project that needs this? At work, I am
behind a firewall that has made doing anything websocket related
cumbersome.

Ω Alisson

unread,
Jan 28, 2011, 1:51:25 PM1/28/11
to knock...@googlegroups.com
You don't need websocket support to use this, it can fallback to flashsocket or xhr long polling or xhr multipart streaming or jsonp polling or forever iframe...

No, I'm not using it on active project. I had an epiphany and done this in 2 days, so pardon me if the code is buggy :)

thelinuxlich

unread,
Feb 21, 2011, 2:03:01 PM2/21/11
to KnockoutJS
Plugin updated with following changes:

- Now we don't need to pass the object hierarchy as string; just
call .live() and you're good
- Primitive temporary storage on server-side. When the user connects,
it loads all live observable values

thelinuxlich

unread,
Feb 22, 2011, 10:01:17 AM2/22/11
to KnockoutJS
Plugin updated with following changes:

- Options parameter for live(), so we can do this:
{
id: "my_id", //custom sync ID(useful to sync different apps with the
same observable)
readonly: true //Default is false. It blocks any direct change to
the observable, it will accept changes only from the server

Scott Messinger

unread,
Feb 22, 2011, 8:55:13 PM2/22/11
to knock...@googlegroups.com
Does the backend have to be node.js or could it be any backend connected via websockets?

-Scott

2011/2/22 thelinuxlich <thelin...@gmail.com>

kgvi...@gmail.com

unread,
Feb 23, 2011, 8:42:29 AM2/23/11
to knock...@googlegroups.com
Awesome stuff, I have the same question as Scott.
Any example of making this work with aspnet/mvc ?? would be great.

Cheers,
Vin

Ω Alisson

unread,
Feb 23, 2011, 8:51:32 AM2/23/11
to knock...@googlegroups.com
I want to add compatibility with a lot of backends besides node.js + socket.io(juggernaut, faye, google channels, etc). I don't have any experience with this stuff in .NET world. If someone could help me, it's pretty simple to add support :)

WellDone

unread,
Aug 3, 2011, 12:47:22 PM8/3/11
to knock...@googlegroups.com
Is there a url available to demo the plugin? thanks

Ω Alisson

unread,
Aug 3, 2011, 1:17:29 PM8/3/11
to knock...@googlegroups.com
Sorry, too busy at the moment to setup a demo online, but if you clone the project repo, there is a demo there (just run "node server.js") 

benperth

unread,
Sep 6, 2011, 10:11:31 AM9/6/11
to KnockoutJS
Is this project still active? Or do you know of a more recent solution
(using socket.io 0.7)?

Ω Alisson

unread,
Sep 6, 2011, 1:55:49 PM9/6/11
to knock...@googlegroups.com
Hey, I've just updated it for compatibility with socket.io 0.7+ :)

2011/9/6 benperth <south...@gmail.com>

benperth

unread,
Sep 7, 2011, 9:21:00 AM9/7/11
to KnockoutJS
Legend, thanks :)

On Sep 6, 6:55 pm, Ω Alisson <thelinuxl...@gmail.com> wrote:
> Hey, I've just updated it for compatibility with socket.io 0.7+ :)
>
> 2011/9/6 benperth <southall...@gmail.com>
Reply all
Reply to author
Forward
0 new messages