Merge pull request #548 from ethereum/eventManager

EventManager fix use event with anonymous obj
pull/1/head
yann300 8 years ago committed by GitHub
commit 10cdc1dcb4
  1. 2
      src/app.js
  2. 2
      src/app/compiler.js
  3. 2
      src/app/editor.js
  4. 2
      src/app/execution-context.js
  5. 2
      src/app/file-explorer.js
  6. 2
      src/app/file-panel.js
  7. 2
      src/app/files.js
  8. 2
      src/app/formalVerification.js
  9. 65
      src/lib/eventManager.js
  10. 2
      src/universal-dapp.js

@ -22,7 +22,7 @@ var ExecutionContext = require('./app/execution-context')
var UniversalDApp = require('./universal-dapp.js') var UniversalDApp = require('./universal-dapp.js')
var Debugger = require('./app/debugger') var Debugger = require('./app/debugger')
var FormalVerification = require('./app/formalVerification') var FormalVerification = require('./app/formalVerification')
var EventManager = require('./lib/eventManager') var EventManager = require('ethereum-remix').lib.EventManager
var StaticAnalysis = require('./app/staticanalysis/staticAnalysisView') var StaticAnalysis = require('./app/staticanalysis/staticAnalysisView')
var OffsetToLineColumnConverter = require('./lib/offsetToLineColumnConverter') var OffsetToLineColumnConverter = require('./lib/offsetToLineColumnConverter')
var FilePanel = require('./app/file-panel') var FilePanel = require('./app/file-panel')

@ -6,7 +6,7 @@ var solcABI = require('solc/abi')
var webworkify = require('webworkify') var webworkify = require('webworkify')
var utils = require('./utils') var utils = require('./utils')
var EventManager = require('../lib/eventManager') var EventManager = require('ethereum-remix').lib.EventManager
/* /*
trigger compilationFinished, compilerLoaded, compilationStarted trigger compilationFinished, compilerLoaded, compilationStarted

@ -1,6 +1,6 @@
'use strict' 'use strict'
var EventManager = require('../lib/eventManager') var EventManager = require('ethereum-remix').lib.EventManager
var csjs = require('csjs-inject') var csjs = require('csjs-inject')
var ace = require('brace') var ace = require('brace')

@ -2,7 +2,7 @@
'use strict' 'use strict'
var Web3 = require('web3') var Web3 = require('web3')
var EventManager = require('../lib/eventManager') var EventManager = require('ethereum-remix').lib.EventManager
var EthJSVM = require('ethereumjs-vm') var EthJSVM = require('ethereumjs-vm')
var ethUtil = require('ethereumjs-util') var ethUtil = require('ethereumjs-util')
var StateManager = require('ethereumjs-vm/lib/stateManager') var StateManager = require('ethereumjs-vm/lib/stateManager')

@ -3,7 +3,7 @@ var yo = require('yo-yo')
var csjs = require('csjs-inject') var csjs = require('csjs-inject')
var Treeview = require('ethereum-remix').ui.TreeView var Treeview = require('ethereum-remix').ui.TreeView
var EventManager = require('../lib/eventManager') var EventManager = require('ethereum-remix').lib.EventManager
var css = csjs` var css = csjs`
.fileexplorer { .fileexplorer {

@ -2,7 +2,7 @@
var csjs = require('csjs-inject') var csjs = require('csjs-inject')
var yo = require('yo-yo') var yo = require('yo-yo')
var EventManager = require('../lib/eventManager') var EventManager = require('ethereum-remix').lib.EventManager
var FileExplorer = require('./file-explorer') var FileExplorer = require('./file-explorer')
module.exports = filepanel module.exports = filepanel

@ -1,6 +1,6 @@
'use strict' 'use strict'
var EventManager = require('../lib/eventManager') var EventManager = require('ethereum-remix').lib.EventManager
function Files (storage) { function Files (storage) {
var event = new EventManager() var event = new EventManager()

@ -1,7 +1,7 @@
'use strict' 'use strict'
var $ = require('jquery') var $ = require('jquery')
var EventManager = require('../lib/eventManager') var EventManager = require('ethereum-remix').lib.EventManager
/* /*
trigger compilationFinished trigger compilationFinished

@ -1,65 +0,0 @@
'use strict'
function eventManager () {
this.registered = {}
}
/*
* Unregister a listenner.
* Note that if obj is a function. the unregistration will be applied to the dummy obj {}.
*
* @param {String} eventName - the event name
* @param {Object or Func} obj - object that will listen on this event
* @param {Func} func - function of the listenners that will be executed
*/
eventManager.prototype.unregister = function (eventName, obj, func) {
if (obj instanceof Function) {
func = obj
obj = {}
}
for (var reg in this.registered[eventName]) {
if (this.registered[eventName][reg] &&
this.registered[eventName][reg].obj === obj && (!func || this.registered[eventName][reg].func === func)) {
this.registered[eventName].splice(reg, 1)
return
}
}
}
/*
* Register a new listenner.
* Note that if obj is a function, the function registration will be associated with the dummy object {}
*
* @param {String} eventName - the event name
* @param {Object or Func} obj - object that will listen on this event
* @param {Func} func - function of the listenners that will be executed
*/
eventManager.prototype.register = function (eventName, obj, func) {
if (!this.registered[eventName]) {
this.registered[eventName] = []
}
if (obj instanceof Function) {
func = obj
obj = {}
}
this.registered[eventName].push({
obj: obj,
func: func
})
}
/*
* trigger event.
* Every listenner have their associated function executed
*
* @param {String} eventName - the event name
* @param {Array}j - argument that will be passed to the exectued function.
*/
eventManager.prototype.trigger = function (eventName, args) {
for (var listener in this.registered[eventName]) {
var l = this.registered[eventName][listener]
l.func.apply(l.obj, args)
}
}
module.exports = eventManager

@ -5,7 +5,7 @@ var $ = require('jquery')
var ethJSUtil = require('ethereumjs-util') var ethJSUtil = require('ethereumjs-util')
var ethJSABI = require('ethereumjs-abi') var ethJSABI = require('ethereumjs-abi')
var BN = ethJSUtil.BN var BN = ethJSUtil.BN
var EventManager = require('./lib/eventManager') var EventManager = require('ethereum-remix').lib.EventManager
var crypto = require('crypto') var crypto = require('crypto')
var async = require('async') var async = require('async')
var TxRunner = require('./app/txRunner') var TxRunner = require('./app/txRunner')

Loading…
Cancel
Save