enqueueJSCall instead of global dynamic require

Summary:
BridgeProfiling.setEnabled used a one off eval. Let's use the bridge to do this like everything else. This is already what the Android equivalent is doing.

public

Reviewed By: tadeuzagallo

Differential Revision: D2745059

fb-gh-sync-id: 5b633365b8cfc8abc6b80255e82ef3053ead9b50
This commit is contained in:
Sebastian Markbage 2015-12-11 16:35:36 -08:00 коммит произвёл facebook-github-bot-9
Родитель 836ba8fb38
Коммит 2696f9440e
1 изменённых файлов: 1 добавлений и 5 удалений

Просмотреть файл

@ -417,11 +417,7 @@ static void RCTInstallJSCProfiler(RCTBridge *bridge, JSContextRef context)
{
[self executeBlockOnJavaScriptQueue:^{
BOOL enabled = [notification.name isEqualToString:RCTProfileDidStartProfiling];
// TODO: Don't use require, go through the normal execution modes instead. #9317773
NSString *script = [NSString stringWithFormat:@"var p = require('Systrace') || {}; p.setEnabled && p.setEnabled(%@)", enabled ? @"true" : @"false"];
JSStringRef scriptJSRef = JSStringCreateWithUTF8CString(script.UTF8String);
JSEvaluateScript(_context.ctx, scriptJSRef, NULL, NULL, 0, NULL);
JSStringRelease(scriptJSRef);
[_bridge enqueueJSCall:@"Systrace.setEnabled" args:@[enabled ? @YES : @NO]];
}];
}