Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
fmauNeko committed Mar 22, 2024
2 parents 1751f46 + 09770ee commit a660dea
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 4 deletions.
9 changes: 5 additions & 4 deletions index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
export * from './lib/engine';
export * from "./lib/engine";

export * from './lib/synchronizer';
export * from "./lib/synchronizer";

export * from './lib/config';
export * from "./lib/config";

export * from './lib/crud';
export * from "./lib/crud";

export * from "./lib/utils";
29 changes: 29 additions & 0 deletions lib/utils/Ask.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
export type AskEventDefinition = {
name: string;
payload: any;
result: any;
};

export type AskEventHandler<
TAskEventDefinition extends AskEventDefinition = AskEventDefinition
> = (
payload?: TAskEventDefinition["payload"]
) => Promise<TAskEventDefinition["result"]>;

export function onAsk<
TAskEventDefinition extends AskEventDefinition = AskEventDefinition
>(
event: TAskEventDefinition["name"],
handler: AskEventHandler<TAskEventDefinition>
) {
return global.kuzzle.onAsk(event, handler);
}

export async function ask<
TAskEventDefinition extends AskEventDefinition = AskEventDefinition
>(
event: TAskEventDefinition["name"],
payload?: TAskEventDefinition["payload"]
): Promise<TAskEventDefinition["result"]> {
return global.kuzzle.ask(event, payload);
}
1 change: 1 addition & 0 deletions lib/utils/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from "./Ask";

0 comments on commit a660dea

Please sign in to comment.