jeudi 30 août 2018

how to clone an ember object

I am creating an object like:

let response = Ember.object.create({
               propertyOne: value1
              });

I am using it in the end, and set it as one of the property of model like this:

let userRecord = this.get('store').createRecord('user');
userRecord.set('prop', response.propertyOne);

Now when I do model.save then in my adapter, I am overriding createRecord method where I convert any camelcase property to snake case before sending it on wire. If it fails, then I will retry but the problem is next time I retry, the created object gets modified. I guess it is because i am passing the object and setting on the model as a reference. is there a way to duplicate the ember object so that this can be avoided?




Aucun commentaire:

Enregistrer un commentaire