|
5 | 5 | injectable, |
6 | 6 | postConstruct, |
7 | 7 | } from '@theia/core/shared/inversify'; |
8 | | -import { Emitter } from '@theia/core/lib/common/event'; |
| 8 | +import { Emitter, Event } from '@theia/core/lib/common/event'; |
9 | 9 | import { ArduinoCoreServiceClient } from './cli-protocol/cc/arduino/cli/commands/v1/commands_grpc_pb'; |
10 | 10 | import { Instance } from './cli-protocol/cc/arduino/cli/commands/v1/common_pb'; |
11 | 11 | import { |
@@ -53,6 +53,8 @@ export class CoreClientProvider { |
53 | 53 | private readonly onClientReadyEmitter = |
54 | 54 | new Emitter<CoreClientProvider.Client>(); |
55 | 55 | private readonly onClientReady = this.onClientReadyEmitter.event; |
| 56 | + private readonly onClientDidRefreshEmitter = |
| 57 | + new Emitter<CoreClientProvider.Client>(); |
56 | 58 |
|
57 | 59 | @postConstruct() |
58 | 60 | protected init(): void { |
@@ -88,6 +90,10 @@ export class CoreClientProvider { |
88 | 90 | return this.pending.promise; |
89 | 91 | } |
90 | 92 |
|
| 93 | + get onClientDidRefresh(): Event<CoreClientProvider.Client> { |
| 94 | + return this.onClientDidRefreshEmitter.event; |
| 95 | + } |
| 96 | + |
91 | 97 | /** |
92 | 98 | * Encapsulates both the gRPC core client creation (`CreateRequest`) and initialization (`InitRequest`). |
93 | 99 | */ |
@@ -253,6 +259,7 @@ export class CoreClientProvider { |
253 | 259 | await this.initInstance(client); |
254 | 260 | // notify clients about the index update only after the client has been "re-initialized" and the new content is available. |
255 | 261 | progressHandler.reportEnd(); |
| 262 | + this.onClientDidRefreshEmitter.fire(client); |
256 | 263 | } catch (err) { |
257 | 264 | console.error('Failed to update indexes', err); |
258 | 265 | progressHandler.reportError( |
@@ -404,6 +411,10 @@ export abstract class CoreClientAware { |
404 | 411 | protected get coreClient(): Promise<CoreClientProvider.Client> { |
405 | 412 | return this.coreClientProvider.client; |
406 | 413 | } |
| 414 | + |
| 415 | + protected get onClientDidRefresh(): Event<CoreClientProvider.Client> { |
| 416 | + return this.coreClientProvider.onClientDidRefresh; |
| 417 | + } |
407 | 418 | } |
408 | 419 |
|
409 | 420 | class IndexUpdateRequiredBeforeInitError extends Error { |
|
0 commit comments