Skip to content

Commit 0b47134

Browse files
authored
import specific parts of rxjs to speed up loading (microsoft#596)
Fixes microsoft#449
1 parent 71e45bc commit 0b47134

File tree

4 files changed

+14
-20
lines changed

4 files changed

+14
-20
lines changed

src/client/common/process/proc.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
import { spawn } from 'child_process';
55
import { inject, injectable } from 'inversify';
6-
import * as Rx from 'rxjs';
6+
import { Observable } from 'rxjs/Observable';
77
import { Disposable } from 'vscode';
88
import { createDeferred } from '../helpers';
99
import { DEFAULT_ENCODING } from './constants';
@@ -29,7 +29,7 @@ export class ProcessService implements IProcessService {
2929
const proc = spawn(file, args, spawnOptions);
3030
let procExited = false;
3131

32-
const output = new Rx.Observable<Output<string>>(subscriber => {
32+
const output = new Observable<Output<string>>(subscriber => {
3333
const disposables: Disposable[] = [];
3434

3535
const on = (ee: NodeJS.EventEmitter, name: string, fn: Function) => {

src/client/common/process/types.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// Licensed under the MIT License.
33

44
import { ChildProcess, SpawnOptions as ChildProcessSpawnOptions } from 'child_process';
5-
import * as Rx from 'rxjs';
5+
import { Observable } from 'rxjs/Observable';
66
import { CancellationToken, Uri } from 'vscode';
77
import { ExecutionInfo } from '../types';
88
import { EnvironmentVariables } from '../variables/types';
@@ -18,7 +18,7 @@ export type Output<T extends string | Buffer> = {
1818
};
1919
export type ObservableExecutionResult<T extends string | Buffer> = {
2020
proc: ChildProcess;
21-
out: Rx.Observable<Output<T>>;
21+
out: Observable<Output<T>>;
2222
};
2323

2424
// tslint:disable-next-line:interface-name

src/test/install/pythonInstallation.test.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,10 @@
33
'use strict';
44

55
import * as assert from 'assert';
6-
import { ChildProcess, SpawnOptions } from 'child_process';
76
import { Container } from 'inversify';
8-
import * as Rx from 'rxjs';
97
import * as TypeMoq from 'typemoq';
10-
import * as vscode from 'vscode';
118
import { IApplicationShell } from '../../client/common/application/types';
129
import { IPythonSettings } from '../../client/common/configSettings';
13-
import { STANDARD_OUTPUT_CHANNEL } from '../../client/common/constants';
1410
import { PythonInstaller } from '../../client/common/installer/pythonInstallation';
1511
import { IPlatformService } from '../../client/common/platform/types';
1612
import { IInterpreterLocatorService } from '../../client/interpreter/contracts';

src/test/mocks/proc.ts

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,40 @@
1-
import { spawn } from 'child_process';
21
import { EventEmitter } from 'events';
3-
import { decorate, inject, injectable } from 'inversify';
4-
import * as Rx from 'rxjs';
5-
import { Disposable } from 'vscode';
6-
import { ExecutionResult, IBufferDecoder, IProcessService, ObservableExecutionResult, Output, SpawnOptions } from '../../client/common/process/types';
2+
import { inject, injectable } from 'inversify';
3+
import 'rxjs/add/observable/of';
4+
import { Observable } from 'rxjs/Observable';
5+
import { ExecutionResult, IProcessService, ObservableExecutionResult, Output, SpawnOptions } from '../../client/common/process/types';
76

8-
type ExecObservableCallback = (result: Rx.Observable<Output<string>> | Output<string>) => void;
7+
type ExecObservableCallback = (result: Observable<Output<string>> | Output<string>) => void;
98
type ExecCallback = (result: ExecutionResult<string>) => void;
109

1110
export const IOriginalProcessService = Symbol('IProcessService');
1211

1312
@injectable()
1413
export class MockProcessService extends EventEmitter implements IProcessService {
15-
private observableResults: (Rx.Observable<Output<string>> | Output<string>)[] = [];
1614
constructor( @inject(IOriginalProcessService) private procService: IProcessService) {
1715
super();
1816
}
1917
public onExecObservable(handler: (file: string, args: string[], options: SpawnOptions, callback: ExecObservableCallback) => void) {
2018
this.on('execObservable', handler);
2119
}
2220
public execObservable(file: string, args: string[], options: SpawnOptions = {}): ObservableExecutionResult<string> {
23-
let value: Rx.Observable<Output<string>> | Output<string> | undefined;
21+
let value: Observable<Output<string>> | Output<string> | undefined;
2422
let valueReturned = false;
25-
this.emit('execObservable', file, args, options, (result: Rx.Observable<Output<string>> | Output<string>) => { value = result; valueReturned = true; });
23+
this.emit('execObservable', file, args, options, (result: Observable<Output<string>> | Output<string>) => { value = result; valueReturned = true; });
2624

2725
if (valueReturned) {
2826
const output = value as Output<string>;
2927
if (['stderr', 'stdout'].some(source => source === output.source)) {
3028
return {
3129
// tslint:disable-next-line:no-any
3230
proc: {} as any,
33-
out: Rx.Observable.of(output)
31+
out: Observable.of(output)
3432
};
3533
} else {
3634
return {
3735
// tslint:disable-next-line:no-any
3836
proc: {} as any,
39-
out: value as Rx.Observable<Output<string>>
37+
out: value as Observable<Output<string>>
4038
};
4139
}
4240
} else {
@@ -51,6 +49,6 @@ export class MockProcessService extends EventEmitter implements IProcessService
5149
let valueReturned = false;
5250
this.emit('exec', file, args, options, (result: ExecutionResult<string>) => { value = result; valueReturned = true; });
5351

54-
return valueReturned ? value : this.procService.exec(file, args, options);
52+
return valueReturned ? value! : this.procService.exec(file, args, options);
5553
}
5654
}

0 commit comments

Comments
 (0)