Refactor serialization
This commit is contained in:
parent
8e44dd3733
commit
b3da27e73b
1 changed files with 142 additions and 133 deletions
16
shared/src/transport/serialization/serializable.ts
Normal file
16
shared/src/transport/serialization/serializable.ts
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
import { SerializableClass } from './serializable-class';
|
||||
import { serializableMapping } from './serializable-mapping';
|
||||
|
||||
export const serializable = (type: SerializableClass): any => {
|
||||
if (!serializableMapping.get(type.name)) {
|
||||
serializableMapping.set(type.name, {
|
||||
constructor: type,
|
||||
overriden: false,
|
||||
});
|
||||
}
|
||||
|
||||
Object.defineProperty(type, '__serializable_type', { value: type.name });
|
||||
Object.defineProperty(type.prototype, '__serializable_type', { value: type.name });
|
||||
|
||||
return type;
|
||||
};
|
||||
Loading…
Reference in a new issue