Пример #1
0
        /* Do async cancellable WWW request. */
        public static Cancellable <Future <Either <Cancelled, Either <WWWError, WWW> > > > toFuture(this WWW www)
        {
            Promise <Either <Cancelled, Either <WWWError, WWW> > > promise;
            var f = Future <Either <Cancelled, Either <WWWError, WWW> > > .async(out promise);

            var wwwCoroutine = StartCoroutine(WWWEnumerator(www, promise));

            return(Cancellable.a(f, () => {
                if (www.isDone)
                {
                    return false;
                }

                wwwCoroutine.stop();
                www.Dispose();
                promise.complete(new Either <Cancelled, Either <WWWError, WWW> >(Cancelled.instance));
                return true;
            }));
        }
Пример #2
0
 public static Cancellable <Future <Either <Cancelled, Either <WWWError, Texture2D> > > > asTexture(
     this Cancellable <Future <Either <Cancelled, Either <WWWError, WWW> > > > cancellable
     ) => cancellable.map(f => f.map(e => e.mapRight(_ => _.asTexture())));
Пример #3
0
 public static Future <A> asNonCancellable <A>(
     this Cancellable <Future <Either <Cancelled, A> > > cancellable
     ) => cancellable.value.flatMap(e => e.fold(
                                        cancelled => Future <A> .unfulfilled,
                                        Future.successful
                                        ));