You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
is there any example for using @Serialize.Custom with this optinal properties in the TypeSerializer<TSerialized, TOriginal> interface?
/**
* _Optional._ Original type constructor function.
* Default: Value of `design:type` for given property.
*/
type?: Constructable.Default<TOriginal>;
/**
* _Optional._ Property type descriminator function.
* Used to narrow type constructor function (e.g. for union types)
* @param serialized Serialized value
* @returns Original type constructor function
*/
discriminate?(this: void, serialized: TSerialized): Constructable.Default<TOriginal>;
I google the code go in deep for the inflate and deflate function and can not even find, that this two properties are used. I want to use the discriminate function to map the name of a type, stored in a serialized string property to a type via a "typemapper".
Thanks for help!
Georg
The text was updated successfully, but these errors were encountered:
This discriminate functionality was never fully implemented. Later I decided that it adds unnecessary complexity to the library and the same effect can be achieved by providing custom up/down functions. So, I removed it completely in v3 (develop branch, can be installed with npm i serialazy@next). Also, you can check a CHANGELOG for more info on changes.
Hello,
thanks for the interesst! May be you find some inspiration or you just shake your head.
I want to compine polymorphism with generics and want to define the serialisation in the generic. To do this I defined an interface "NamedType", an interface that yust defined the the property "public typeName: string" witch will be serialised (and will be transported over axios or some like that). So I will serialize some thing like an Array (or List-, Tree- or Collection- Generic) of for example a "Person" - Class with can in detail be instance of "Teacher" or "Student" witch extends "Person". So up/inflate the generic Array has to translate the array elements with typeName="Teacher" to a instance of Teacher - Class and typeName="Student" to an Student - Class. I try to define this mapping in the Array generic (or Tree generic) and only want to define the mapper like (typeName: string) => T later on the level I want to use the generic.
I hope I make it clear, I dont expect a solution. I am still working on my challange.
Hello,
is there any example for using @Serialize.Custom with this optinal properties in the TypeSerializer<TSerialized, TOriginal> interface?
I google the code go in deep for the inflate and deflate function and can not even find, that this two properties are used. I want to use the discriminate function to map the name of a type, stored in a serialized string property to a type via a "typemapper".
Thanks for help!
Georg
The text was updated successfully, but these errors were encountered: