Get rid of the initialize method

This commit is contained in:
Ben Ogle
2016-02-25 16:33:39 -08:00
parent 1cd530cdf0
commit 418b1bd8f1
3 changed files with 9 additions and 11 deletions

View File

@@ -8,8 +8,9 @@ describe('AutoUpdateManager (renderer)', () => {
let autoUpdateManager
beforeEach(() => {
autoUpdateManager = new AutoUpdateManager()
autoUpdateManager.initialize(atom.applicationDelegate)
autoUpdateManager = new AutoUpdateManager({
applicationDelegate: atom.applicationDelegate
})
})
afterEach(() => {

View File

@@ -192,8 +192,7 @@ class AtomEnvironment extends Model
@themes.workspace = @workspace
@textEditors = new TextEditorRegistry
@autoUpdater = new AutoUpdateManager
@autoUpdater.initialize(@applicationDelegate)
@autoUpdater = new AutoUpdateManager({@applicationDelegate})
@config.load()

View File

@@ -4,23 +4,21 @@ import {Emitter, CompositeDisposable} from 'event-kit'
import {ipcRenderer} from 'electron'
export default class AutoUpdateManager {
constructor () {
constructor ({applicationDelegate}) {
this.subscriptions = new CompositeDisposable()
this.emitter = new Emitter()
}
initialize (updateEventEmitter) {
this.subscriptions.add(
updateEventEmitter.onDidBeginCheckingForUpdate(() => {
applicationDelegate.onDidBeginCheckingForUpdate(() => {
this.emitter.emit('did-begin-checking-for-update')
}),
updateEventEmitter.onDidBeginDownloadingUpdate(() => {
applicationDelegate.onDidBeginDownloadingUpdate(() => {
this.emitter.emit('did-begin-downloading-update')
}),
updateEventEmitter.onDidCompleteDownloadingUpdate((details) => {
applicationDelegate.onDidCompleteDownloadingUpdate((details) => {
this.emitter.emit('did-complete-downloading-update', details)
}),
updateEventEmitter.onUpdateNotAvailable(() => {
applicationDelegate.onUpdateNotAvailable(() => {
this.emitter.emit('update-not-available')
})
)