User `events` and `EventEmitter` instead of `event` and `EventManager`

pull/1/head
Grandschtroumpf 6 years ago committed by yann300
parent 8b2b0fcb52
commit 58df39d458
  1. 15
      src/app/files/fileManager.js
  2. 2
      src/app/panels/editor-panel.js
  3. 8
      src/app/panels/tab-proxy.js
  4. 2
      src/app/plugin/pluginManager.js
  5. 3
      src/app/tabs/compile-tab.js
  6. 2
      src/app/tabs/runTab/model/dropdownlogic.js
  7. 2
      src/app/tabs/test-tab.js

@ -1,7 +1,6 @@
'use strict' 'use strict'
const EventEmitter = require('events') const EventEmitter = require('events')
var EventManager = require('../../lib/events')
var globalRegistry = require('../../global/registry') var globalRegistry = require('../../global/registry')
var CompilerImport = require('../compiler/compiler-imports') var CompilerImport = require('../compiler/compiler-imports')
@ -13,7 +12,6 @@ var CompilerImport = require('../compiler/compiler-imports')
class FileManager { class FileManager {
constructor (localRegistry) { constructor (localRegistry) {
this.openedFiles = {} // list all opened files this.openedFiles = {} // list all opened files
this.event = new EventManager()
this.events = new EventEmitter() this.events = new EventEmitter()
this._components = {} this._components = {}
this._components.compilerImport = new CompilerImport() this._components.compilerImport = new CompilerImport()
@ -43,9 +41,6 @@ class FileManager {
self._deps.localhostExplorer.event.register('errored', (event) => { this.removeTabsOf(self._deps.localhostExplorer) }) self._deps.localhostExplorer.event.register('errored', (event) => { this.removeTabsOf(self._deps.localhostExplorer) })
self._deps.localhostExplorer.event.register('closed', (event) => { this.removeTabsOf(self._deps.localhostExplorer) }) self._deps.localhostExplorer.event.register('closed', (event) => { this.removeTabsOf(self._deps.localhostExplorer) })
self.event.register('currentFileChanged', (file, provider) => {
this.events.emit('currentFileChanged', file)
})
} }
profile () { profile () {
@ -84,7 +79,7 @@ class FileManager {
this.switchFile(newFocus) this.switchFile(newFocus)
} }
} }
this.event.trigger('fileRenamed', [oldName, newName]) this.events.emit('fileRenamed', oldName, newName)
} }
currentFileProvider () { currentFileProvider () {
@ -107,7 +102,7 @@ class FileManager {
this._deps.editor.displayEmptyReadOnlySession() this._deps.editor.displayEmptyReadOnlySession()
this._deps.config.set('currentFile', '') this._deps.config.set('currentFile', '')
} }
this.event.trigger('fileClosed', [name]) this.events.emit('fileClosed', name)
} }
currentPath () { currentPath () {
@ -167,7 +162,7 @@ class FileManager {
} }
self._deps.editor.discard(path) self._deps.editor.discard(path)
delete this.openedFiles[path] delete this.openedFiles[path]
this.event.trigger('fileRemoved', [path]) this.events.emit('fileRemoved', path)
this.switchFile() this.switchFile()
} }
@ -182,7 +177,7 @@ class FileManager {
if (fileList.length) { if (fileList.length) {
_switchFile(browserProvider.type + '/' + fileList[0]) _switchFile(browserProvider.type + '/' + fileList[0])
} else { } else {
self.event.trigger('currentFileChanged', []) self.events.emit('currentFileChanged')
self._deps.editor.displayEmptyReadOnlySession() self._deps.editor.displayEmptyReadOnlySession()
} }
}) })
@ -200,7 +195,7 @@ class FileManager {
} else { } else {
self._deps.editor.open(file, content) self._deps.editor.open(file, content)
} }
self.event.trigger('currentFileChanged', [file, self.fileProviderOf(file)]) self.events.emit('currentFileChanged', file)
} }
}) })
} }

@ -61,7 +61,7 @@ class EditorPanel {
We listen here on event from the tab component to display / hide the editor and mainpanel We listen here on event from the tab component to display / hide the editor and mainpanel
depending on the content that should be displayed depending on the content that should be displayed
*/ */
self._deps.fileManager.event.register('currentFileChanged', (file) => { self._deps.fileManager.events.on('currentFileChanged', (file) => {
// we check upstream for "fileChanged" // we check upstream for "fileChanged"
self._view.editor.style.display = 'block' self._view.editor.style.display = 'block'
self._components.contextView.show() self._components.contextView.show()

@ -15,15 +15,15 @@ export class TabProxy {
this._view = {} this._view = {}
this._handlers = {} this._handlers = {}
fileManager.event.register('fileRemoved', (name) => { fileManager.events.on('fileRemoved', (name) => {
this.removeTab(name) this.removeTab(name)
}) })
fileManager.event.register('fileClosed', (name) => { fileManager.events.on('fileClosed', (name) => {
this.removeTab(name) this.removeTab(name)
}) })
fileManager.event.register('currentFileChanged', (file) => { fileManager.events.on('currentFileChanged', (file) => {
if (this._handlers[file]) { if (this._handlers[file]) {
this._view.filetabs.activateTab(file) this._view.filetabs.activateTab(file)
return return
@ -38,7 +38,7 @@ export class TabProxy {
}) })
}) })
fileManager.event.register('fileRenamed', (oldName, newName) => { fileManager.events.on('fileRenamed', (oldName, newName) => {
this.removeTab(oldName) this.removeTab(oldName)
this.addTab(newName, () => { this.addTab(newName, () => {
this.fileManager.switchFile(newName) this.fileManager.switchFile(newName)

@ -93,7 +93,7 @@ module.exports = class PluginManager {
self.plugins = {} self.plugins = {}
self.origins = {} self.origins = {}
self.inFocus self.inFocus
fileManager.event.register('currentFileChanged', (file, provider) => { fileManager.events.on('currentFileChanged', (file) => {
self.broadcast(JSON.stringify({ self.broadcast(JSON.stringify({
action: 'notification', action: 'notification',
key: 'editor', key: 'editor',

@ -75,12 +75,13 @@ class CompileTab {
} }
}) })
this._deps.fileManager.event.register('currentFileChanged', (name) => { this._deps.fileManager.events.on('currentFileChanged', (name) => {
this.compilerContainer.currentFile = name this.compilerContainer.currentFile = name
}) })
this.compiler.event.register('compilationFinished', (success, data, source) => { this.compiler.event.register('compilationFinished', (success, data, source) => {
if (success) { if (success) {
// forwarding the event to the appManager infra // forwarding the event to the appManager infra
console.log(source.target, source, this.data.selectedVersion, data)
this.events.emit('compilationFinished', source.target, source, this.data.selectedVersion, data) this.events.emit('compilationFinished', source.target, source, this.data.selectedVersion, data)
// Store the contracts // Store the contracts
this.data.contractsDetails = {} this.data.contractsDetails = {}

@ -21,7 +21,7 @@ class DropdownLogic {
this.listenToCompilationEvents() this.listenToCompilationEvents()
fileManager.event.register('currentFileChanged', (currentFile) => { fileManager.events.on('currentFileChanged', (currentFile) => {
this.event.trigger('currentFileChanged', [currentFile]) this.event.trigger('currentFileChanged', [currentFile])
}) })
} }

@ -116,7 +116,7 @@ module.exports = class TestTab {
self.data.selectedTests.push(file) self.data.selectedTests.push(file)
}) })
self._deps.fileManager.event.register('currentFileChanged', (file, provider) => { self._deps.fileManager.events.on('currentFileChanged', (file) => {
getTests(self, (error, tests) => { getTests(self, (error, tests) => {
if (error) return tooltip(error) if (error) return tooltip(error)
self.data.allTests = tests self.data.allTests = tests

Loading…
Cancel
Save