Exemple #1
0
        public static PromiseCapability CreateFromConstructor(RuntimeObject constructor)
        {
            Guard.ArgumentNotNull(constructor, "constructor");
            PromiseCapability capability = new PromiseCapability();

            capability.Promise = constructor.Construct((Action <EcmaValue, EcmaValue>)capability.Executor);
            capability.EnsureValidResolver();
            return(capability);
        }
Exemple #2
0
        public static PromiseCapability Create()
        {
            PromiseCapability capability = new PromiseCapability();

            capability.Promise = new Promise((resolve, reject) => {
                capability.ResolveCallback = resolve;
                capability.RejectCallback  = reject;
            });
            return(capability);
        }
Exemple #3
0
        public override EcmaValue Resume(GeneratorResumeState state, EcmaValue value)
        {
            PromiseCapability capability = PromiseCapability.Create();
            ResumeRecord      record     = new ResumeRecord(state, value, capability);

            queue.Enqueue(record);
            if (this.State != GeneratorState.Running)
            {
                ResumeNext();
            }
            return(capability.Promise);
        }
Exemple #4
0
 public PromiseAggregator(PromiseCapability capability)
 {
     Guard.ArgumentNotNull(capability, "capability");
     this.capability = capability;
 }