eventManager removed

pull/1573/head
aniket-engg 3 years ago committed by Aniket
parent 3ead354c47
commit 156f9ae2d1
  1. 2
      apps/remix-ide/src/app/tabs/test-tab.js
  2. 2
      libs/remix-tests/src/compiler.ts
  3. 68
      libs/remix-tests/src/lib/eventManager.ts
  4. 4
      libs/remix-tests/src/runTestSources.ts

@ -98,7 +98,7 @@ module.exports = class TestTab extends ViewPlugin {
this.setCurrentPath(this.defaultPath)
})
this.testRunner.event.register('compilationFinished', (success, data, source) => {
this.testRunner.event.on('compilationFinished', (success, data, source) => {
if (success) {
this.allFilesInvolved = Object.keys(data.sources)
// forwarding the event to the appManager infra

@ -205,7 +205,7 @@ export function compileContractSources (sources: SrcIfc, compilerConfig: Compile
function doCompilation (next) {
// @ts-ignore
compiler.event.register('compilationFinished', this, (success, data, source) => {
if (opts && opts.event) opts.event.trigger('compilationFinished', [success, data, source])
if (opts && opts.event) opts.event.emit('compilationFinished', success, data, source)
next(null, data)
})
compiler.compile(sources, filepath)

@ -1,68 +0,0 @@
'use strict'
export default class EventManager {
registered: any = {} // eslint-disable-line
anonymous: any = {} // eslint-disable-line
/*
* Unregister a listener.
* 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 listeners that will be executed
*/
unregister (eventName: any, obj: any, func: any): void { // eslint-disable-line
if (!this.registered[eventName]) {
return
}
if (obj instanceof Function) {
func = obj
obj = this.anonymous
}
for (const reg in this.registered[eventName]) {
if (this.registered[eventName][reg].obj === obj && this.registered[eventName][reg].func === func) {
this.registered[eventName].splice(reg, 1)
}
}
}
/*
* Register a new listener.
* 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 listeners that will be executed
*/
register (eventName: any, obj: any, func: any): void { // eslint-disable-line
if (!this.registered[eventName]) {
this.registered[eventName] = []
}
if (obj instanceof Function) {
func = obj
obj = this.anonymous
}
this.registered[eventName].push({
obj: obj,
func: func
})
}
/*
* trigger event.
* Every listener have their associated function executed
*
* @param {String} eventName - the event name
* @param {Array}j - argument that will be passed to the executed function.
*/
trigger (eventName: any, args: any): void { // eslint-disable-line
if (!this.registered[eventName]) {
return
}
for (const listener in this.registered[eventName]) {
const l = this.registered[eventName][listener]
if (l.func) l.func.apply(l.obj === this.anonymous ? {} : l.obj, args)
}
}
}

@ -5,7 +5,7 @@ import { deployAll } from './deployer'
import { runTest } from './testRunner'
import Web3 from 'web3'
import EventManager from './lib/eventManager'
import { EventEmitter } from 'events'
import { Provider, extend } from '@remix-project/remix-simulator'
import {
FinalResult, SrcIfc, compilationInterface, ASTInterface, Options,
@ -17,7 +17,7 @@ export class UnitTestRunner {
event
constructor () {
this.event = new EventManager()
this.event = new EventEmitter()
}
async createWeb3Provider () {

Loading…
Cancel
Save