Open jpradelle opened 7 years ago
In fact, we can pass callbacks to child elements by defining them like this:
filterCallback: {
type: Object,
value: function () {
return function (item) {
return item.active;
}.bind(this);
}
},
And then we just need to pass this property through one-way binding. The child element will be able to call this callback to filter items.
@arthurevans any ideas for people on the Polymer team who can help answer this?
@katejeffreys I'll try to add some detail here...
Type: constructor (one of Boolean, Date, Number, String, Array or Object)
is a little misleading. Those are they types which Polymer understands how to serialize/deserialize. You can still provide another type, like Function
for documentation, and to opt out of serialization (since Polymer won't know what to do). If you then want to enable serialization, you do so via _serializevalue
.
In practice though, serializing non-primitive values is rare and it's fine to leave that out, in which case the type is mostly documentation.
Should add doc for custom serializing/deserializing. And add upgrade guide note about serialize=>_serializeValue etc.
In release note of v1.3.0 there is a sample code using "type: Function" in properties definition https://www.polymer-project.org/1.0/docs/release-notes#v1-3-0-dynamic-fns
But in documentation there is nothing about Function type. In declare properties page https://www.polymer-project.org/2.0/docs/devguide/properties :
And nothing about Function in the documentation. Maybe a doc chapter is missing, or Function type should be avoided and might not be supported in future versions ?
More generally custom serialization is not clear:
And nothing about deserialization
In PropertyAccessors mixin source code it seems we can implement any type we want and override serialize and deserialize, but as this is not in polymer-project.org doc, will it be maintained in future releases ?