Skip to content

Conversation

@tejaede
Copy link
Collaborator

@tejaede tejaede commented May 31, 2018

DataTrigger.addTrigger() overrides the getter and setter for a property on a prototype to route that property through montage-data. However, addTrigger() does not include the serializable attribute for that property as defined in the model.

This means that if a prototype declares a property as not serializable:

var MyClass = Montage.specialize({
   children: {
       value: undefined,
       writable: false
   }
});

A serialized instance of that class will not include children. This is expected.
However, if DataTrigger.addTriggers() is called on the prototype and then we use the result to create an instance. That serialized instance will include children.

var myClassA = new MyClass();
var myClassB = Object.create(MyClass.prototype);


// Add triggers using the DataService, ObjectDescriptor, and Prototype
// This is the prototype that the DataService will cache and use to create instances
var montageDataPrototype = Object.create(MyClass.prototype);

DataTriggers.addTriggers(aService, objectDescriptor, montageDataPrototype) 
var myClassC = Object.create(montageDataPrototype); 

var serializedA = serializer.serializeObject(myClassA); //No children
var serializedB = serializer.serializeObject(myClassB); //No children

var serializedC = serializer.serializeObject(myClassC); //Has children

@tejaede tejaede self-assigned this May 31, 2018
@tejaede tejaede requested a review from marchant May 31, 2018 17:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants