Quantcast
Channel: JavaScriptMVC Forum
Viewing all articles
Browse latest Browse all 3491

Making UN-Observables

$
0
0
Hi

In the context of live binding it is normal that an interactive app makes extensive changes to an observable.

If such changes need to be persisted my approach has been to (try) and reverse the process of creating the observable (can.Map / whatever) and recreate the equivalent POJS Object. It's a bit ugly, it's definitely hacky and there has to be a better way, No !?

I quite often save an entire POJS object in serialised form then I can just Ajax for it whenever I want to continue. Storage might be local or a back end DB.

given that

var observable = new can.Map(my large and complicated object) ...

... do load of work on observable ...

then I want to

var rawObj = can.UnMap(observable) ; // or something similar to recover my large, and now amended, complicated object
save(rawObj);

Is there a can.Onical way to do this, to recreate raw from cooked ? If not then I guess I'll have to stick to the existing hackery which works but I suspect is probably rather fragile.

Ron Yuen

Viewing all articles
Browse latest Browse all 3491

Trending Articles