taking care of connection during creation
This commit is contained in:
parent
46da72ab64
commit
e93e50c43c
@ -124,6 +124,8 @@ const main = async function () {
|
||||
return;
|
||||
}
|
||||
|
||||
await dispatcher.ready.waitFor(value => value);
|
||||
|
||||
const sleep = promisify(setTimeout);
|
||||
await sleep(1000);
|
||||
|
||||
|
@ -26,12 +26,19 @@ export function getLinkedDispatcher(options: INopeRpcDispatcherOptions) {
|
||||
|
||||
const dispatcher = getDispatcher(options);
|
||||
|
||||
// Iterate over the Functions
|
||||
for (const [uri, settings] of container.instance.entries()) {
|
||||
dispatcher.registerFunction(settings.callback, {
|
||||
id: uri
|
||||
});
|
||||
}
|
||||
// If the Dispatcher has been connected, register all functions.
|
||||
dispatcher.ready.waitFor(value => value).then(() => {
|
||||
if (dispatcher.ready.getContent()){
|
||||
// Iterate over the Functions
|
||||
for (const [uri, settings] of container.instance.entries()) {
|
||||
dispatcher.registerFunction(settings.callback, {
|
||||
id: uri
|
||||
});
|
||||
}
|
||||
} else {
|
||||
console.log('Failed')
|
||||
}
|
||||
});
|
||||
|
||||
return dispatcher;
|
||||
}
|
||||
|
@ -24,6 +24,8 @@ export type IValidPromise<T> = Promise<T> | INopePromise<T>;
|
||||
* @interface INopeDispatcher
|
||||
*/
|
||||
export interface INopeDispatcher {
|
||||
|
||||
readonly ready: INopeObservable<boolean>;
|
||||
|
||||
/**
|
||||
* ID of the Dispatcher
|
||||
|
Loading…
Reference in New Issue
Block a user