|
7 | 7 |
|
8 | 8 | import { TPromise } from 'vs/base/common/winjs.base'; |
9 | 9 | import { IChannel, eventToCall, eventFromCall } from 'vs/base/parts/ipc/common/ipc'; |
10 | | -import Event, { Emitter, any, mapEvent } from 'vs/base/common/event'; |
| 10 | +import Event, { Emitter } from 'vs/base/common/event'; |
11 | 11 | import { onUnexpectedError } from 'vs/base/common/errors'; |
12 | | -import { memoize } from 'vs/base/common/decorators'; |
13 | 12 | import { IUpdateService, IRawUpdate, State, IUpdate } from './update'; |
14 | 13 |
|
15 | 14 | export interface IUpdateChannel extends IChannel { |
@@ -59,25 +58,24 @@ export class UpdateChannelClient implements IUpdateService { |
59 | 58 | private _onUpdateReady = eventFromCall<IRawUpdate>(this.channel, 'event:onUpdateReady'); |
60 | 59 | get onUpdateReady(): Event<IRawUpdate> { return this._onUpdateReady; } |
61 | 60 |
|
62 | | - private _onInitialStateChange = new Emitter<State>(); |
63 | 61 | private _onRemoteStateChange = eventFromCall<State>(this.channel, 'event:onStateChange'); |
64 | | - |
65 | | - @memoize |
66 | | - get onStateChange(): Event<State> { |
67 | | - const result = any(this._onInitialStateChange.event, this._onRemoteStateChange); |
68 | | - |
69 | | - return mapEvent(result, state => { |
70 | | - this._state = state; |
71 | | - return state; |
72 | | - }); |
73 | | - } |
| 62 | + private _onStateChange = new Emitter<State>(); |
| 63 | + get onStateChange(): Event<State> { return this._onStateChange.event; } |
74 | 64 |
|
75 | 65 | private _state: State = State.Uninitialized; |
76 | 66 | get state(): State { return this._state; }; |
77 | 67 |
|
78 | 68 | constructor(private channel: IUpdateChannel) { |
79 | | - channel.call('_getInitialState') |
80 | | - .done(state => this._onInitialStateChange.fire(state), onUnexpectedError); |
| 69 | + // always set this._state as the state changes |
| 70 | + this.onStateChange(state => this._state = state); |
| 71 | + |
| 72 | + channel.call('_getInitialState').done(state => { |
| 73 | + // fire initial state |
| 74 | + this._onStateChange.fire(state); |
| 75 | + |
| 76 | + // fire subsequent states as they come in from remote |
| 77 | + this._onRemoteStateChange(s => this._onStateChange.fire(state)); |
| 78 | + }, onUnexpectedError); |
81 | 79 | } |
82 | 80 |
|
83 | 81 | checkForUpdates(explicit: boolean): TPromise<IUpdate> { |
|
0 commit comments