You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
What is the best, or just a good, practice for loading and saving relational data in Polymer elements' published properties?
I've used https://github.com/PaulUithol/Backbone-relational to load and save relational data. It depends on Backbone. But now with Polymer's use of Object.observe(), I mostly don't need Backbone's complex model objects (at least I don't need their get() and set() methods), but I can't figure out how I can best get rid of Backbone's complex model objects and just use plain JavaScript objects AND load and save relational data to my data store.
Is there a Polymer-compatible library/web component out there which already implements this? Or a native way to do it?
Here are a couple ways I could do it myself without a library, but I expect I'm missing lots of edge cases.
1.Loadrelational data:
// Load from servermodel=store.get('model-id');// model == {'id':'abc', 'name':'Parent', child_ids:['child-id1', 'child-id2']}for(child_idinmodel.child_ids){model.children[child_id]=store.get(child_id);}// Use model in Polymer element's published property here2.Save relational data:
// Get model from Polymer published property heremodel.child_ids=[];for(childinmodel.children){model.child_ids.push(child.id);}deletemodel.children;store.set(JSON.stringify(model));// or just store.set(model);
The text was updated successfully, but these errors were encountered:
What is the best, or just a good, practice for loading and saving relational data in Polymer elements' published properties?
I've used https://github.com/PaulUithol/Backbone-relational to load and save relational data. It depends on Backbone. But now with Polymer's use of Object.observe(), I mostly don't need Backbone's complex model objects (at least I don't need their get() and set() methods), but I can't figure out how I can best get rid of Backbone's complex model objects and just use plain JavaScript objects AND load and save relational data to my data store.
Is there a Polymer-compatible library/web component out there which already implements this? Or a native way to do it?
Here are a couple ways I could do it myself without a library, but I expect I'm missing lots of edge cases.
The text was updated successfully, but these errors were encountered: