use node-compatible event emitter

This commit is contained in:
Mark Vayngrib 2015-05-17 16:55:38 -04:00
parent 6f328cca63
commit 6827e29118
2 changed files with 10 additions and 9 deletions

View File

@ -12,8 +12,9 @@
'use strict';
var inherits = require('inherits')
var EventEmitter = require('events').EventEmitter
var React = require('react-native')
var mixInEventEmitter = require('mixInEventEmitter')
var DeviceEventEmitter = require('RCTDeviceEventEmitter')
var Sockets = require('NativeModules').UdpSockets
var base64 = require('base64-js')
@ -26,6 +27,8 @@ var STATE = {
}
function UdpSocket(type) {
EventEmitter.call(this)
this._id = instances++
this._state = STATE.UNBOUND
this._subscription = DeviceEventEmitter.addListener(
@ -40,6 +43,8 @@ function UdpSocket(type) {
}) // later
}
inherits(UdpSocket, EventEmitter)
UdpSocket.prototype._debug = function() {
// for now
var args = [].slice.call(arguments)
@ -222,11 +227,4 @@ UdpSocket.prototype.unref = function() {
// anything?
}
mixInEventEmitter(UdpSocket, {
'listening': true,
'message': true,
'close': true,
'error': true
})
module.exports = UdpSocket

View File

@ -33,6 +33,9 @@
"homepage": "https://github.com/tradle/react-native-udp",
"dependencies": {
"base64-js": "0.0.8",
"react-native": "^0.4.2"
"events": "^1.0.2",
"inherits": "^2.0.1",
"react-native": "^0.4.2",
"util": "^0.10.3"
}
}