mirror of https://github.com/status-im/metro.git
[ReactNative] Add ability to listen for Packager events
This commit is contained in:
parent
daf56c32eb
commit
44b97249e9
|
@ -22,6 +22,7 @@ exports.middleware = function(options) {
|
||||||
return server.processRequest.bind(server);
|
return server.processRequest.bind(server);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
exports.activityEvents = Activity.eventEmitter;
|
||||||
|
|
||||||
// Renamed "package" to "bundle". But maintain backwards
|
// Renamed "package" to "bundle". But maintain backwards
|
||||||
// compat.
|
// compat.
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var chalk = require('chalk');
|
var chalk = require('chalk');
|
||||||
|
var events = require('events');
|
||||||
|
|
||||||
var COLLECTION_PERIOD = 1000;
|
var COLLECTION_PERIOD = 1000;
|
||||||
|
|
||||||
|
@ -18,6 +19,7 @@ var _queuedActions = [];
|
||||||
var _scheduledCollectionTimer = null;
|
var _scheduledCollectionTimer = null;
|
||||||
var _uuid = 1;
|
var _uuid = 1;
|
||||||
var _enabled = true;
|
var _enabled = true;
|
||||||
|
var _eventEmitter = new events.EventEmitter();
|
||||||
|
|
||||||
function endEvent(eventId) {
|
function endEvent(eventId) {
|
||||||
var eventEndTime = Date.now();
|
var eventEndTime = Date.now();
|
||||||
|
@ -98,6 +100,7 @@ function _runCollection() {
|
||||||
|
|
||||||
function _scheduleAction(action) {
|
function _scheduleAction(action) {
|
||||||
_queuedActions.push(action);
|
_queuedActions.push(action);
|
||||||
|
_eventEmitter.emit(action.action, action);
|
||||||
|
|
||||||
if (_scheduledCollectionTimer === null) {
|
if (_scheduledCollectionTimer === null) {
|
||||||
_scheduledCollectionTimer = setTimeout(_runCollection, COLLECTION_PERIOD);
|
_scheduledCollectionTimer = setTimeout(_runCollection, COLLECTION_PERIOD);
|
||||||
|
@ -171,3 +174,4 @@ exports.endEvent = endEvent;
|
||||||
exports.signal = signal;
|
exports.signal = signal;
|
||||||
exports.startEvent = startEvent;
|
exports.startEvent = startEvent;
|
||||||
exports.disable = disable;
|
exports.disable = disable;
|
||||||
|
exports.eventEmitter = _eventEmitter;
|
||||||
|
|
Loading…
Reference in New Issue