Skip to content

Commit

Permalink
[inversify] work around construction injection limitation, prob relat…
Browse files Browse the repository at this point in the history
…ed to es6 (Object.keys)

see #2451

Signed-off-by: Alex Tugarev <alex.tugarev@typefox.io>
  • Loading branch information
AlexTugarev authored and akosyakov committed Jul 31, 2018
1 parent b439750 commit 74e5ac7
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
23 changes: 10 additions & 13 deletions packages/core/src/browser/connection-status-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
********************************************************************************/

import { inject, injectable, optional } from 'inversify';
import { inject, injectable, optional, postConstruct } from 'inversify';
import { ILogger } from '../common/logger';
import { Event, Emitter } from '../common/event';
import { DefaultFrontendApplicationContribution } from './frontend-application';
Expand Down Expand Up @@ -83,11 +83,10 @@ export abstract class AbstractConnectionStatusService implements ConnectionStatu
protected connectionStatus: ConnectionStatus = ConnectionStatus.ONLINE;
protected timer: number | undefined;

constructor(
@inject(ConnectionStatusOptions) @optional() protected readonly options: ConnectionStatusOptions = ConnectionStatusOptions.DEFAULT,
@inject(ILogger) protected readonly logger: ILogger
) {
}
@inject(ILogger)
protected readonly logger: ILogger;

constructor(@inject(ConnectionStatusOptions) @optional() protected readonly options: ConnectionStatusOptions = ConnectionStatusOptions.DEFAULT) { }

get onStatusChange() {
return this.statusChangeEmitter.event;
Expand Down Expand Up @@ -143,13 +142,11 @@ export class FrontendConnectionStatusService extends AbstractConnectionStatusSer

private scheduledPing: number | undefined;

constructor(
@inject(WebSocketConnectionProvider) protected readonly wsConnectionProvider: WebSocketConnectionProvider,
@inject(PingService) protected readonly pingService: PingService,
@inject(ConnectionStatusOptions) @optional() protected readonly options: ConnectionStatusOptions = ConnectionStatusOptions.DEFAULT,
@inject(ILogger) protected readonly logger: ILogger
) {
super(options, logger);
@inject(WebSocketConnectionProvider) protected readonly wsConnectionProvider: WebSocketConnectionProvider;
@inject(PingService) protected readonly pingService: PingService;

@postConstruct()
protected init() {
this.schedulePing();
this.wsConnectionProvider.onIncomingMessageActivity(() => {
// natural activity
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,16 @@

import { MockLogger } from '../../common/test/mock-logger';
import { AbstractConnectionStatusService } from '../connection-status-service';
import { ILogger } from '@theia/core/src/common';

export class MockConnectionStatusService extends AbstractConnectionStatusService {

protected readonly logger: ILogger = new MockLogger();

constructor() {
super({
offlineTimeout: 10
}, new MockLogger());
});
}

public set alive(alive: boolean) {
Expand Down

0 comments on commit 74e5ac7

Please sign in to comment.