JavaScriptErrorCode NotifyModuleReadyCallback( JavaScriptModuleRecord referencingModule, JavaScriptValue exceptionVar ) { Loader.Debug($"Javascript.Module.RecordDelegate NotifyModuleReadyCallback evaluating module: '{referencingModule.HostUrl}'"); executeRoot = () => { referencingModule.Evaluate(); // will throw if exceptionVar was set }; return(JavaScriptErrorCode.NoError); // this return value is ignored! (wiki) }
/// <summary> /// User implemented callback to get notification when the module is ready. /// </summary> /// <remarks> /// The callback is invoked on the current runtime execution thread, therefore execution is blocked until the /// callback completes. This callback should schedule a call to JsEvaluateModule to run the module that has been loaded. /// </remarks> /// <param name="referencingModule">The referencing module that has finished running ModuleDeclarationInstantiation step.</param> /// <param name="exceptionVar">If nullptr, the module is successfully initialized and host should queue the execution job /// otherwise it's the exception object.</param> /// <returns> /// Returns a JsErrorCode - note, the return value is ignored. /// </returns> /// <see cref="NotifyModuleReadyCallback"></see> private JavaScriptErrorCode ModuleLoadedImpl(JavaScriptModuleRecord referencingModule, JavaScriptValue exceptionVar) { if (!exceptionVar.IsValid) { _dispatcher.Invoke(() => { using (_context.GetScope()) { referencingModule.Evaluate(); if (referencingModule.Equals(RootModule)) { OnRootModuleEvaluated?.Invoke(); } } }); } return(JavaScriptErrorCode.NoError); }