Reputation: 1696
I have client application where I want to clone an item and send it to the server and only when the server send notification - to update the entity. is the detachEntity is the only solution? as i want to be able to clone the item and not remove it from the cache
Upvotes: 0
Views: 324
Reputation: 14995
Pseudo-code goes here -
var thisEntity = getEntity();
var newEntity;
var myPropArray = [];
for each property in entity { copy property; myPropArray.push(property) }
var params = JSON.stringify(myPropArray);
newEntity = manager.createEntity('MyEntityType', params);
...
Profit.
Upvotes: 1
Reputation: 17052
You can export the specific entity and import it into another entityManager. This is effectively a clone.
var exportedEntities = entityManager1.exportEntities([myEntity]);
var clonedEntities = entityManager2.importEntities(exportedEntities);
Upvotes: 1