@aire-ux/aire-condensation
Version:
Client-side serialization library for Aire-UX
35 lines (34 loc) • 1.15 kB
JavaScript
import { Condensation } from "./condensation";
export function Remotable(type) {
Condensation.remoteRegistry.register(type);
// return type;
}
const ctx = Condensation.defaultContext();
export function Receive(type) {
return (target, key, index) => {
if (!key) {
Condensation.remoteRegistry.defineParameter(target, {
type: type,
index: index,
invocationType: "constructor",
invocationTarget: "constructor",
});
}
else {
Condensation.remoteRegistry.defineParameter(target.constructor, {
type: type,
index: index,
invocationTarget: key,
invocationType: "method",
});
}
};
}
export function Remote(target, propertyKey, descriptor) {
const original = descriptor.value;
descriptor.value = function (...args) {
const formals = ctx.formalParams(target.constructor, 'method', propertyKey, ...args);
return original.apply(this, formals);
// return original.bind(target).apply(target, ...formals);
};
}