Skip to content

Commit

Permalink
feat: provide progress parameter via fold pending parameter
Browse files Browse the repository at this point in the history
closes #20
  • Loading branch information
Malte Legenhausen authored and raveclassic committed Nov 6, 2018
1 parent 45b2c47 commit 291161b
Showing 1 changed file with 25 additions and 5 deletions.
30 changes: 25 additions & 5 deletions src/remote-data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,12 @@ export class RemoteInitial<L, A> {
*
* rest of example is similar to `fold`
*/
foldL<B>(initial: Lazy<B>, pending: Lazy<B>, failure: Function1<L, B>, success: Function1<A, B>): B {
foldL<B>(
initial: Lazy<B>,
pending: Function1<Option<RemoteProgress>, B>,
failure: Function1<L, B>,
success: Function1<A, B>,
): B {
return initial();
}

Expand Down Expand Up @@ -441,7 +446,12 @@ export class RemoteFailure<L, A> {
return failure(this.error);
}

foldL<B>(initial: Lazy<B>, pending: Lazy<B>, failure: Function1<L, B>, success: Function1<A, B>): B {
foldL<B>(
initial: Lazy<B>,
pending: Function1<Option<RemoteProgress>, B>,
failure: Function1<L, B>,
success: Function1<A, B>,
): B {
return failure(this.error);
}

Expand Down Expand Up @@ -553,7 +563,12 @@ export class RemoteSuccess<L, A> {
return success(this.value);
}

foldL<B>(initial: Lazy<B>, pending: Lazy<B>, failure: Function1<L, B>, success: Function1<A, B>): B {
foldL<B>(
initial: Lazy<B>,
pending: Function1<Option<RemoteProgress>, B>,
failure: Function1<L, B>,
success: Function1<A, B>,
): B {
return success(this.value);
}

Expand Down Expand Up @@ -670,8 +685,13 @@ export class RemotePending<L, A> {
return pending;
}

foldL<B>(initial: Lazy<B>, pending: Lazy<B>, failure: Function1<L, B>, success: Function1<A, B>): B {
return pending();
foldL<B>(
initial: Lazy<B>,
pending: Function1<Option<RemoteProgress>, B>,
failure: Function1<L, B>,
success: Function1<A, B>,
): B {
return pending(this.progress);
}

getOrElseL(f: Lazy<A>): A {
Expand Down

0 comments on commit 291161b

Please sign in to comment.