@@ -236,47 +236,51 @@ std::string simpleBasename(const std::string& path) {
236
236
*/
237
237
void ReactInstance::loadScript (
238
238
std::unique_ptr<const JSBigString> script,
239
- const std::string& sourceURL) {
239
+ const std::string& sourceURL,
240
+ std::function<void (jsi::Runtime& runtime)>&& completion) {
240
241
auto buffer = std::make_shared<BigStringBuffer>(std::move (script));
241
242
std::string scriptName = simpleBasename (sourceURL);
242
243
243
- runtimeScheduler_->scheduleWork (
244
- [this ,
245
- scriptName,
246
- sourceURL,
247
- buffer = std::move (buffer),
248
- weakBufferedRuntimeExecuter = std::weak_ptr<BufferedRuntimeExecutor>(
249
- bufferedRuntimeExecutor_)](jsi::Runtime& runtime) {
250
- SystraceSection s (" ReactInstance::loadScript" );
251
- bool hasLogger (ReactMarker::logTaggedMarkerBridgelessImpl);
252
- if (hasLogger) {
253
- ReactMarker::logTaggedMarkerBridgeless (
254
- ReactMarker::RUN_JS_BUNDLE_START, scriptName.c_str ());
255
- }
244
+ runtimeScheduler_->scheduleWork ([this ,
245
+ scriptName,
246
+ sourceURL,
247
+ buffer = std::move (buffer),
248
+ weakBufferedRuntimeExecuter =
249
+ std::weak_ptr<BufferedRuntimeExecutor>(
250
+ bufferedRuntimeExecutor_),
251
+ completion](jsi::Runtime& runtime) {
252
+ SystraceSection s (" ReactInstance::loadScript" );
253
+ bool hasLogger (ReactMarker::logTaggedMarkerBridgelessImpl);
254
+ if (hasLogger) {
255
+ ReactMarker::logTaggedMarkerBridgeless (
256
+ ReactMarker::RUN_JS_BUNDLE_START, scriptName.c_str ());
257
+ }
256
258
257
- runtime.evaluateJavaScript (buffer, sourceURL);
259
+ runtime.evaluateJavaScript (buffer, sourceURL);
258
260
259
- /* *
260
- * TODO(T183610671): We need a safe/reliable way to enable the js
261
- * pipeline from javascript. Remove this after we figure that out, or
262
- * after we just remove the js pipeline.
263
- */
264
- if (!jsErrorHandler_->hasHandledFatalError ()) {
265
- jsErrorHandler_->setRuntimeReady ();
266
- }
261
+ /* *
262
+ * TODO(T183610671): We need a safe/reliable way to enable the js
263
+ * pipeline from javascript. Remove this after we figure that out, or
264
+ * after we just remove the js pipeline.
265
+ */
266
+ if (!jsErrorHandler_->hasHandledFatalError ()) {
267
+ jsErrorHandler_->setRuntimeReady ();
268
+ }
267
269
268
- if (hasLogger) {
269
- ReactMarker::logTaggedMarkerBridgeless (
270
- ReactMarker::RUN_JS_BUNDLE_STOP, scriptName.c_str ());
271
- ReactMarker::logMarkerBridgeless (
272
- ReactMarker::INIT_REACT_RUNTIME_STOP);
273
- ReactMarker::logMarkerBridgeless (ReactMarker::APP_STARTUP_STOP);
274
- }
275
- if (auto strongBufferedRuntimeExecuter =
276
- weakBufferedRuntimeExecuter.lock ()) {
277
- strongBufferedRuntimeExecuter->flush ();
278
- }
279
- });
270
+ if (hasLogger) {
271
+ ReactMarker::logTaggedMarkerBridgeless (
272
+ ReactMarker::RUN_JS_BUNDLE_STOP, scriptName.c_str ());
273
+ ReactMarker::logMarkerBridgeless (ReactMarker::INIT_REACT_RUNTIME_STOP);
274
+ ReactMarker::logMarkerBridgeless (ReactMarker::APP_STARTUP_STOP);
275
+ }
276
+ if (auto strongBufferedRuntimeExecuter =
277
+ weakBufferedRuntimeExecuter.lock ()) {
278
+ strongBufferedRuntimeExecuter->flush ();
279
+ }
280
+ if (completion) {
281
+ completion (runtime);
282
+ }
283
+ });
280
284
}
281
285
282
286
/*
0 commit comments