/// <summary> /// Creates a new Promise instance. /// </summary> /// <param name="prototype"></param> /// <param name="executor"></param> internal PromiseInstance(ObjectInstance prototype, FunctionInstance executor) : base(prototype) { FunctionInstance resolveFunc = new ClrStubFunction(Engine.FunctionInstancePrototype, (engine, thisObj, param) => { this.state = PromiseState.Fulfilled; if (param.Length > 0) { result = param[0]; } return(Undefined.Value); }); FunctionInstance rejectFunc = new ClrStubFunction(Engine.FunctionInstancePrototype, (engine, thisObj, param) => { this.state = PromiseState.Rejected; if (param.Length > 0) { result = param[0]; } return(Undefined.Value); }); try { executor.Call(Undefined.Value, resolveFunc, rejectFunc); } catch (JavaScriptException ex) { rejectFunc.Call(Undefined.Value, ex.ErrorObject); } }
/// <summary> /// Creates a new Promise instance. /// </summary> /// <param name="prototype"></param> /// <param name="executor"></param> internal PromiseInstance(ObjectInstance prototype, FunctionInstance executor) : base(prototype) { FunctionInstance resolveFunc = new ClrStubFunction(Engine.FunctionInstancePrototype, (engine, thisObj, param) => { return(Undefined.Value); }); FunctionInstance rejectFunc = new ClrStubFunction(Engine.FunctionInstancePrototype, (engine, thisObj, param) => { return(Undefined.Value); }); try { executor.Call(Undefined.Value, resolveFunc, rejectFunc); } catch (JavaScriptException ex) { rejectFunc.Call(Undefined.Value, ex.ErrorObject); } }
/// <summary> /// Creates a new Promise instance. /// </summary> /// <param name="prototype"></param> /// <param name="executor"></param> internal PromiseInstance(ObjectInstance prototype, FunctionInstance executor) : base(prototype) { FunctionInstance resolveFunc = new ClrStubFunction(Engine.FunctionInstancePrototype, (engine, thisObj, param) => { return Undefined.Value; }); FunctionInstance rejectFunc = new ClrStubFunction(Engine.FunctionInstancePrototype, (engine, thisObj, param) => { return Undefined.Value; }); try { executor.Call(Undefined.Value, resolveFunc, rejectFunc); } catch (JavaScriptException ex) { rejectFunc.Call(Undefined.Value, ex.ErrorObject); } }