/* 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; })); }
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())));
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 ));