Skip to content

Commit 1f50b85

Browse files
committed
Enable asynchronous configuration loading and configuration signal
Signed-off-by: Jacob Schlecht <dadadah@echoha.us>
1 parent e1a9c8a commit 1f50b85

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

src/Client.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,9 @@ export class Client extends AsyncEventEmitter<Events> {
188188
readonly ready: Accessor<boolean>;
189189
#setReady: Setter<boolean>;
190190

191+
readonly configured: Accessor<boolean>;
192+
#setConfigured: Setter<boolean>;
193+
191194
readonly connectionFailureCount: Accessor<number>;
192195
#setConnectionFailureCount: Setter<number>;
193196
#reconnectTimeout: number | undefined;
@@ -239,6 +242,12 @@ export class Client extends AsyncEventEmitter<Events> {
239242
baseURL: this.options.baseURL,
240243
});
241244

245+
const [configured, setConfigured] = createSignal(configuration !== undefined);
246+
this.configured = configured;
247+
this.#setConfigured = setConfigured;
248+
249+
this.#fetchConfiguration();
250+
242251
const [ready, setReady] = createSignal(false);
243252
this.ready = ready;
244253
this.#setReady = setReady;
@@ -328,6 +337,7 @@ export class Client extends AsyncEventEmitter<Events> {
328337
async #fetchConfiguration(): Promise<void> {
329338
if (!this.configuration) {
330339
this.configuration = await this.api.get("/");
340+
this.#setConfigured(true);
331341
}
332342
}
333343

0 commit comments

Comments
 (0)