From 7946160733796abe391dc2fb6a7293de5ec483bc Mon Sep 17 00:00:00 2001 From: Felix Oghina Date: Fri, 22 Apr 2016 11:23:21 -0700 Subject: [PATCH] refactor BugReporting to use RCTDeviceEventEmitter Reviewed By: sahrens Differential Revision: D3212300 fb-gh-sync-id: 3a61d620320dd1c0254bf3b836601d5bbfbc4c0d fbshipit-source-id: 3a61d620320dd1c0254bf3b836601d5bbfbc4c0d --- Libraries/BugReporting/BugReporting.js | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/Libraries/BugReporting/BugReporting.js b/Libraries/BugReporting/BugReporting.js index b8bb24aac..dc6967d97 100644 --- a/Libraries/BugReporting/BugReporting.js +++ b/Libraries/BugReporting/BugReporting.js @@ -11,8 +11,10 @@ */ 'use strict'; -const BatchedBridge = require('BatchedBridge'); const BugReportingNativeModule = require('NativeModules').BugReporting; +const RCTDeviceEventEmitter = require('RCTDeviceEventEmitter'); + +import type {EmitterSubscription} from 'EventEmitter'; type ExtraData = { [key: string]: string }; type SourceCallback = () => string; @@ -26,15 +28,16 @@ type SourceCallback = () => string; class BugReporting { static _sources: Map = new Map(); + static _subscription: EmitterSubscription = null; /** * `init` is called in `AppRegistry.runApplication`, so you shouldn't have to worry about it. */ static init() { - BatchedBridge.registerCallableModule( // idempotent - 'BugReporting', - BugReporting, - ); + if (!BugReporting._subscription) { + BugReporting._subscription = RCTDeviceEventEmitter + .addListener('collectBugExtraData', BugReporting.collectExtraData, null); + } } /**