There is such a code
static GetPromise(Target: NetObjectinterface, name: any, args: any[]) { let key = window.CallNetMethod(0, "GetUniqueString"); let promise = new Promise((resolve, reject) => { NetObject.PromiseDictioanary.set(key, { resolve: resolve, reject: reject }); window.CallAsyncNetObjectFunction(Target.Id, name, key, args); }); return promise; } static SetPromiseResult(Successfully: boolean, TaskId: string, result: any) { let item = NetObject.PromiseDictioanary.get(TaskId); try { NetObject.PromiseDictioanary.delete(TaskId); //result = NetObject.WrapResult(result, true); if (Successfully) item.resolve(result); // Ошибка при установке Proxy else item.reject(result); } catch (e) { item.reject("ошибка установки асинхронного результата " + e); alert("ошибка установки асинхронного результата " + e); } } If the result is an object type, then I need to wrap it in Proxy.
static WrapResult(value: any, ReturnProxy: boolean = false): any { if (typeof value == "object") { if ("IsNetObject" in value) { let res = getNetObject(value.Id); if (ReturnProxy) return new Proxy(res, NetObjectHandler); else return res } } return value; } But if I install
item.resolve(NetObject.WrapResult(result, true)); then the error "not found then" falls out
Exit after getting the result set.
let document = await Context.async.OpenAsync(address); document = NetObject.WrapResult(document, true); Perhaps the problem is that the source for the proxy is the function
function getNetObject(id: number): NetObjectinterface { let netObject = <NetObjectinterface>function (start: number) { }; netObject.Id = id; netObject.isNetObject = true; netObject[NetObject.isNetclass] = true; netObject.Execute = NetObject.Execute; netObject.CallAsProp = NetObject.CallAsProp; return netObject; } And she really has no then
Here I posted the source code CEF, Es6, Angular 2, TypeScript using .Net Core classes to expand the possibilities
where can i try this bug
itemis taken from thePromiseDictioanary? What will happen if you create a newPromise, and not take the old one? - Pavel Mayorov