lambder 2.0.2 → 2.0.3
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/dist/Lambder.d.ts +4 -4
- package/dist/Lambder.js +3 -2
- package/package.json +1 -1
- package/src/Lambder.ts +8 -7
package/dist/Lambder.d.ts
CHANGED
|
@@ -124,10 +124,10 @@ export default class Lambder<TSessionData = any, _TContract extends Record<strin
|
|
|
124
124
|
input: TInput;
|
|
125
125
|
output: TOutput;
|
|
126
126
|
}, handler: (ctx: LambderSessionRenderContext<z.infer<TInput>, TSessionData>, resolver: LambderResolver<z.infer<TOutput>>) => LambderResolverResponse | Promise<LambderResolverResponse>): Lambder<TSessionData, MergeContract<_TContract, TName, z.infer<TInput>, z.infer<TOutput>>>;
|
|
127
|
-
addHook(hookEvent: 'created', hookFn: HookCreatedFunction, priority?: number): Promise<
|
|
128
|
-
addHook(hookEvent: 'beforeRender', hookFn: HookBeforeRenderFunction, priority?: number):
|
|
129
|
-
addHook(hookEvent: 'afterRender', hookFn: HookAfterRenderFunction, priority?: number):
|
|
130
|
-
addHook(hookEvent: 'fallback', hookFn: HookFallbackFunction, priority?: number):
|
|
127
|
+
addHook(hookEvent: 'created', hookFn: HookCreatedFunction, priority?: number): Promise<this>;
|
|
128
|
+
addHook(hookEvent: 'beforeRender', hookFn: HookBeforeRenderFunction, priority?: number): this;
|
|
129
|
+
addHook(hookEvent: 'afterRender', hookFn: HookAfterRenderFunction, priority?: number): this;
|
|
130
|
+
addHook(hookEvent: 'fallback', hookFn: HookFallbackFunction, priority?: number): this;
|
|
131
131
|
getSessionController(ctx: LambderRenderContext<any> | LambderSessionRenderContext<any, TSessionData>): LambderSessionController<TSessionData>;
|
|
132
132
|
getResponseBuilder(): LambderResponseBuilder<any>;
|
|
133
133
|
private getResolver;
|
package/dist/Lambder.js
CHANGED
|
@@ -250,13 +250,14 @@ export default class Lambder {
|
|
|
250
250
|
});
|
|
251
251
|
return this;
|
|
252
252
|
}
|
|
253
|
-
|
|
253
|
+
addHook(hookEvent, hookFn, priority = 0) {
|
|
254
254
|
if (hookEvent === "created") {
|
|
255
|
-
|
|
255
|
+
return hookFn(this).then(() => this);
|
|
256
256
|
}
|
|
257
257
|
else {
|
|
258
258
|
this.hookList[hookEvent].push({ priority, hookFn });
|
|
259
259
|
this.hookList[hookEvent].sort((a, b) => a.priority - b.priority);
|
|
260
|
+
return this;
|
|
260
261
|
}
|
|
261
262
|
}
|
|
262
263
|
getSessionController(ctx) {
|
package/package.json
CHANGED
package/src/Lambder.ts
CHANGED
|
@@ -361,20 +361,21 @@ export default class Lambder<TSessionData = any, _TContract extends Record<strin
|
|
|
361
361
|
return this as any;
|
|
362
362
|
}
|
|
363
363
|
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
364
|
+
addHook(hookEvent: 'created', hookFn: HookCreatedFunction, priority?: number): Promise<this>;
|
|
365
|
+
addHook(hookEvent: 'beforeRender', hookFn: HookBeforeRenderFunction, priority?: number): this;
|
|
366
|
+
addHook(hookEvent: 'afterRender', hookFn: HookAfterRenderFunction, priority?: number): this;
|
|
367
|
+
addHook(hookEvent: 'fallback', hookFn: HookFallbackFunction, priority?: number): this;
|
|
368
|
+
addHook(
|
|
369
369
|
hookEvent:HookEventType,
|
|
370
370
|
hookFn: HookCreatedFunction & HookBeforeRenderFunction & HookAfterRenderFunction & HookFallbackFunction,
|
|
371
371
|
priority = 0
|
|
372
|
-
): Promise<
|
|
372
|
+
): this | Promise<this> {
|
|
373
373
|
if(hookEvent === "created"){
|
|
374
|
-
|
|
374
|
+
return hookFn(this).then(() => this);
|
|
375
375
|
}else{
|
|
376
376
|
this.hookList[hookEvent].push({ priority, hookFn });
|
|
377
377
|
this.hookList[hookEvent].sort((a, b) => a.priority - b.priority);
|
|
378
|
+
return this;
|
|
378
379
|
}
|
|
379
380
|
}
|
|
380
381
|
|