socket-function 0.117.0 → 0.118.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/SocketFunction.ts +3 -2
- package/package.json +1 -1
package/SocketFunction.ts
CHANGED
|
@@ -129,7 +129,7 @@ export class SocketFunction {
|
|
|
129
129
|
Statics
|
|
130
130
|
>(
|
|
131
131
|
classGuid: string,
|
|
132
|
-
instance: ClassInstance,
|
|
132
|
+
instance: ClassInstance | (() => ClassInstance),
|
|
133
133
|
shapeFnc: () => Shape,
|
|
134
134
|
defaultHooksFnc?: () => SocketExposedShape[""] & {
|
|
135
135
|
onMount?: () => MaybePromise<void>;
|
|
@@ -147,6 +147,7 @@ export class SocketFunction {
|
|
|
147
147
|
noFunctionMeasure?: boolean;
|
|
148
148
|
}
|
|
149
149
|
): SocketRegistered<ExtractShape<ClassInstance, Shape>> & Statics {
|
|
150
|
+
let instanceFnc = lazy(typeof instance === "function" ? instance : () => instance);
|
|
150
151
|
void Promise.resolve().then(() => {
|
|
151
152
|
let onMount = getDefaultHooks?.().onMount;
|
|
152
153
|
if (onMount) {
|
|
@@ -183,7 +184,7 @@ export class SocketFunction {
|
|
|
183
184
|
// by now. This is IMPORTANT, as it allows permissions functions to be moved
|
|
184
185
|
// to a common module, instead of all being inline.
|
|
185
186
|
void Promise.resolve().then(() => {
|
|
186
|
-
registerClass(classGuid,
|
|
187
|
+
registerClass(classGuid, instanceFnc() as SocketExposedInterface, getShape(), {
|
|
187
188
|
noFunctionMeasure: config?.noFunctionMeasure,
|
|
188
189
|
});
|
|
189
190
|
});
|