*hook on core.pluginsLoaded to ensure that we don't answer until all plugins are loaded
This commit is contained in:
parent
3600fbfdcf
commit
58e95806d0
|
@ -1,8 +1,17 @@
|
||||||
import { Plugin, PluginAPI } from "@lumeweb/relay-types";
|
import { Plugin, PluginAPI } from "@lumeweb/relay-types";
|
||||||
|
|
||||||
|
let pluginsLoadedResolve: () => void;
|
||||||
|
let pluginsLoadedPromise = new Promise<void>((resolve) => {
|
||||||
|
pluginsLoadedResolve = resolve;
|
||||||
|
});
|
||||||
|
|
||||||
const plugin: Plugin = {
|
const plugin: Plugin = {
|
||||||
name: "core",
|
name: "core",
|
||||||
async plugin(api: PluginAPI): Promise<void> {
|
async plugin(api: PluginAPI): Promise<void> {
|
||||||
|
api.once("core.pluginsLoaded", () => {
|
||||||
|
pluginsLoadedResolve();
|
||||||
|
});
|
||||||
|
|
||||||
api.registerMethod("ping", {
|
api.registerMethod("ping", {
|
||||||
cacheable: false,
|
cacheable: false,
|
||||||
async handler(): Promise<any> {
|
async handler(): Promise<any> {
|
||||||
|
@ -13,6 +22,10 @@ const plugin: Plugin = {
|
||||||
api.registerMethod("get_methods", {
|
api.registerMethod("get_methods", {
|
||||||
cacheable: false,
|
cacheable: false,
|
||||||
async handler(): Promise<any> {
|
async handler(): Promise<any> {
|
||||||
|
await pluginsLoadedPromise;
|
||||||
|
|
||||||
|
console.log("get_methods", api.rpcServer.getMethods());
|
||||||
|
|
||||||
return api.rpcServer.getMethods();
|
return api.rpcServer.getMethods();
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue