[ReactNative] Add ability to listen for Packager events

This commit is contained in:
Alex Kotliarskyi 2015-08-14 13:58:19 -07:00
parent daf56c32eb
commit 44b97249e9
2 changed files with 5 additions and 0 deletions

View File

@ -22,6 +22,7 @@ exports.middleware = function(options) {
return server.processRequest.bind(server);
};
exports.activityEvents = Activity.eventEmitter;
// Renamed "package" to "bundle". But maintain backwards
// compat.

View File

@ -9,6 +9,7 @@
'use strict';
var chalk = require('chalk');
var events = require('events');
var COLLECTION_PERIOD = 1000;
@ -18,6 +19,7 @@ var _queuedActions = [];
var _scheduledCollectionTimer = null;
var _uuid = 1;
var _enabled = true;
var _eventEmitter = new events.EventEmitter();
function endEvent(eventId) {
var eventEndTime = Date.now();
@ -98,6 +100,7 @@ function _runCollection() {
function _scheduleAction(action) {
_queuedActions.push(action);
_eventEmitter.emit(action.action, action);
if (_scheduledCollectionTimer === null) {
_scheduledCollectionTimer = setTimeout(_runCollection, COLLECTION_PERIOD);
@ -171,3 +174,4 @@ exports.endEvent = endEvent;
exports.signal = signal;
exports.startEvent = startEvent;
exports.disable = disable;
exports.eventEmitter = _eventEmitter;