Skip to content

Commit be78635

Browse files
Malte Legenhausenraveclassic
authored andcommitted
fix: fix bimap, mapLeft, extend to forward progress correctly (#45)
1 parent 43ddf8e commit be78635

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

src/remote-data.ts

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -399,10 +399,20 @@ export const remoteData: Monad2<URI> &
399399
bimap: <L, V, A, B>(fla: RemoteData<L, A>, f: (u: L) => V, g: (a: A) => B): RemoteData<V, B> =>
400400
pipe(
401401
fla,
402-
fold<L, A, RemoteData<V, B>>(() => initial, () => pending, e => failure(f(e)), a => success(g(a))),
402+
fold<L, A, RemoteData<V, B>>(
403+
() => initial,
404+
foldO(() => pending, progress),
405+
e => failure(f(e)),
406+
a => success(g(a)),
407+
),
403408
),
404409
mapLeft: <L, V, A>(fla: RemoteData<L, A>, f: (u: L) => V): RemoteData<V, A> =>
405-
fold<L, A, RemoteData<V, A>>(() => initial, () => pending, e => failure(f(e)), () => fla as any)(fla),
410+
fold<L, A, RemoteData<V, A>>(
411+
() => initial,
412+
foldO(() => pending, progress),
413+
e => failure(f(e)),
414+
() => fla as any,
415+
)(fla),
406416

407417
//Alt
408418
alt: <L, A>(fx: RemoteData<L, A>, fy: () => RemoteData<L, A>): RemoteData<L, A> => fold(fy, fy, fy, () => fx)(fx),
@@ -414,7 +424,12 @@ export const remoteData: Monad2<URI> &
414424
extend: <L, A, B>(fla: RemoteData<L, A>, f: FunctionN<[RemoteData<L, A>], B>): RemoteData<L, B> =>
415425
pipe(
416426
fla,
417-
fold<L, A, RemoteData<L, B>>(() => initial, () => pending, () => fla as any, () => success(f(fla))),
427+
fold<L, A, RemoteData<L, B>>(
428+
() => initial,
429+
foldO(() => pending, progress),
430+
() => fla as any,
431+
() => success(f(fla)),
432+
),
418433
),
419434
};
420435

0 commit comments

Comments
 (0)