Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide progress parameter via fold pending parameter #20

Merged
merged 2 commits into from
Oct 29, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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