Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Libraries/Core/setUpBatchedBridge.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ BatchedBridge.registerLazyCallableModule('JSTimers', () =>
require('./Timers/JSTimers'),
);
BatchedBridge.registerLazyCallableModule('HeapCapture', () =>
require('../Utilities/HeapCapture'),
require('../HeapCapture/HeapCapture'),
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

requiring like this means you should also grab default i think.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i'm not sure if there should be default since export looks like this:

module.exports = HeapCapture;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah gotcha, thought this was coming direct from NativeHeapCapture

);
BatchedBridge.registerLazyCallableModule('SamplingProfiler', () =>
require('../Performance/SamplingProfiler'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@

'use strict';

import NativeHeapCapture from './NativeHeapCapture';

const HeapCapture = {
captureHeap: function(path: string) {
let error = null;
Expand All @@ -20,10 +22,9 @@ const HeapCapture = {
console.log('HeapCapture.captureHeap error: ' + e.toString());
error = e.toString();
}
require('../BatchedBridge/NativeModules').JSCHeapCapture.captureComplete(
path,
error,
);
if (NativeHeapCapture) {
NativeHeapCapture.captureComplete(path, error);
}
},
};

Expand Down
24 changes: 24 additions & 0 deletions Libraries/HeapCapture/NativeHeapCapture.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow
* @format
*/

'use strict';

import type {TurboModule} from 'RCTExport';
import * as TurboModuleRegistry from 'TurboModuleRegistry';
import {Platform} from 'react-native';

export interface Spec extends TurboModule {
+captureHeap: (path: string) => void;
+captureComplete: (path: string, error: ?string) => void;
}

export default (Platform.OS === 'android'
? TurboModuleRegistry.getEnforcing<Spec>('HeapCapture')
: null);