本文整理汇总了TypeScript中events.EventEmitter.call方法的典型用法代码示例。如果您正苦于以下问题:TypeScript EventEmitter.call方法的具体用法?TypeScript EventEmitter.call怎么用?TypeScript EventEmitter.call使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类events.EventEmitter
的用法示例。
在下文中一共展示了EventEmitter.call方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: TwitterWatcher
function TwitterWatcher() {
if (!(this instanceof TwitterWatcher)) {
return new TwitterWatcher();
}
events.EventEmitter.call(this);
}
示例2: Updater
function Updater(time) {
this.time = time;
this.array = [
{number: 1},
{number: 2}
];
var that;
events.EventEmitter.call(this);
this.init = function()
{
that = this;
console.log("Contructor");
//Start interval
setInterval(that.run,that.time);
};
this.run = function()
{
that.array.forEach(function (item) {
if(item.number === 2)
{
that.emit('Event');
}
});
};
}
示例3: constructor
constructor(filename: string) {
super();
EventEmitter.call(this);
this.filename = filename;
this.stack = [];
this.paused = false;
}
示例4: function
export var OrderBook = function(productID: string, websocketURI: string, restURI: string, timeProvider: Utils.ITimeProvider) {
var self = this;
EventEmitter.call(self);
self.productID = productID || 'BTC-USD';
self.websocketURI = websocketURI || 'wss://ws-feed.exchange.coinbase.com';
self.restURI = restURI;
self.state = self.STATES.closed;
self.fail_count = 0;
self.timeProvider = timeProvider;
self.connect();
};
示例5: creator
module[method] = (...args: any) => {
// create new instance of module at runtime if none exists
if (!lazyModule) {
lazyModule = creator()
if (isEventEmitter) EventEmitter.call(lazyModule as any)
}
// check for properties on the prototype chain that aren't functions
if (typeof (lazyModule as any)[method] !== 'function') {
return (lazyModule as any)[method]
}
return (lazyModule as any)[method](...args)
}
示例6: function
var VirtualSerialPort = function(path, options, callback) {
events.EventEmitter.call(this);
console.log("on virtual port ", path);
this.path = path;
var self = this;
this.writeToComputer = function(data) {
self.emit("data", data);
};
if (options.autoOpen) {
process.nextTick(function() {
self.open(callback);
});
}
};
示例7: setApplicationMenu
import { EventEmitter } from 'events'
const bindings = process.atomBinding('app')
const commandLine = process.atomBinding('command_line')
const { app, App } = bindings
// Only one app object permitted.
export default app
const { deprecate, Menu } = electron
let dockMenu: Electron.Menu | null = null
// App is an EventEmitter.
Object.setPrototypeOf(App.prototype, EventEmitter.prototype)
EventEmitter.call(app as any)
Object.assign(app, {
setApplicationMenu (menu: Electron.Menu | null) {
return Menu.setApplicationMenu(menu)
},
getApplicationMenu () {
return Menu.getApplicationMenu()
},
commandLine: {
hasSwitch: (theSwitch: string) => commandLine.hasSwitch(String(theSwitch)),
getSwitchValue: (theSwitch: string) => commandLine.getSwitchValue(String(theSwitch)),
appendSwitch: (theSwitch: string, value?: string) => commandLine.appendSwitch(String(theSwitch), typeof value === 'undefined' ? value : String(value)),
appendArgument: (arg: string) => commandLine.appendArgument(String(arg))
} as Electron.CommandLine,
enableMixedSandbox () {
示例8: Sound
module.exports = function Sound(filename) {
events.EventEmitter.call(this);
this.filename = filename;
};
示例9: constructor
constructor() {
super();
util.inherits(XLSX, events.EventEmitter);
events.EventEmitter.call(this);
}
示例10: Board
//.........这里部分代码省略.........
break;
case FrameTypes.Heartbeat:
var collectingLoops = frameBuffer[1] + (frameBuffer[2] << 8);
var idleLoops = frameBuffer[3] + (frameBuffer[4] << 8);
self.emit('heartbeat', { collectingLoops: collectingLoops, idleLoops: idleLoops, data: new Buffer(frameBuffer).slice(5, frameBuffer.length - 1) });
break;
// FrameType unknown, use a generic frame received callback
default:
// TODO: consider expressing this as multiple params?
self.emit('frame', { sequence: frameSequence, data: new Buffer(frameBuffer) });
break;
}
}
readState = ReadState.FrameStart;
break;
}
}
};
serialPort.on('data', parseFrame);
serialPort.on('open', function() { self.emit('open'); });
serialPort.on('close', function() { self.emit('close'); });
serialPort.on('end', function() { self.emit('end'); });
serialPort.on('error', function(err) { self.emit('error', err); });
events.EventEmitter.call(this);
this.close = function close(callback) {
self.sendFrame(self.FunctionIds.reset);
serialPort.close(callback);
};
this.sendFrame = function sendFrame() {
var frame = new Buffer(0);
for (var i = 0; i < arguments.length; i++) {
var data = arguments[i];
if (!Buffer.isBuffer(data)) {
if (isNaN(data)) {
data = new Buffer(data);
} else {
// Don't allow a number passed as data to be misinterpreted as a buffer length
data = new Buffer([data]);
}
}
frame = Buffer.concat( [frame, data] );
}
// Artificial 8-bit rollover
if (writeSequence === 256) {
writeSequence = 0;
}
// Reinitialize the writeArray and checksum