The registry allows the serializer to handle inheritance.
Example with the default registry:
// Create a new Serializer with the default registry.const serializer = new Serializer();
// Then add registrations to the inner registry.
serializer.registry.add([
{
parent: Foo,
children: {
bar: Bar,
baz: Baz,
}
}
]);
Example with a specific registry:
// Create the registry.const registry = new Registry();
registry.add([
{
parent: Foo,
children: {
bar: Bar,
baz: Baz,
}
}
]);
// Then create a Serializer with a specific registry.const serializer = new Serializer(registry);
// It is always possible to register new classes after, or to add entries to already known classes.
registry.add([
{
parent: Foo,
children: {
bar: NewBar,
}
}
]);
The registry allows the serializer to handle inheritance.
Example with the default registry:
// Create a new Serializer with the default registry. const serializer = new Serializer(); // Then add registrations to the inner registry. serializer.registry.add([ { parent: Foo, children: { bar: Bar, baz: Baz, } } ]);
Example with a specific registry:
// Create the registry. const registry = new Registry(); registry.add([ { parent: Foo, children: { bar: Bar, baz: Baz, } } ]); // Then create a Serializer with a specific registry. const serializer = new Serializer(registry); // It is always possible to register new classes after, or to add entries to already known classes. registry.add([ { parent: Foo, children: { bar: NewBar, } } ]);