Skip to content

Commit

Permalink
refactor(fiber): resumeAsync() returns an UIO<void>
Browse files Browse the repository at this point in the history
BREAKING CHANGE: resumeAsync returns a void instead of a Fiber
  • Loading branch information
tusharmath committed Jul 16, 2019
1 parent d73b10f commit 6988330
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
6 changes: 4 additions & 2 deletions src/internals/FiberContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ export class FiberContext<E = never, A = never> extends Fiber<E, A>
return this
}

public resumeAsync(cb: (exit: Exit<E, A>) => UIO<void>): UIO<Fiber<E, A>> {
public resumeAsync(cb: (exit: Exit<E, A>) => UIO<void>): UIO<void> {
const eee = <X>(con: (x: X) => Exit<E, A>) => (data: X) => {
// tslint:disable-next-line: no-use-before-declare
const cancel = () => this.cancellationList.remove(id)
Expand All @@ -91,6 +91,8 @@ export class FiberContext<E = never, A = never> extends Fiber<E, A>
)
}

return FIO.uio(() => this.$resume(eee(Exit.failure), eee(Exit.success)))
return FIO.uio(
() => void this.$resume(eee(Exit.failure), eee(Exit.success))
)
}
}
2 changes: 1 addition & 1 deletion src/main/Fiber.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,5 @@ export abstract class Fiber<E, A> implements ICancellable {
}
public abstract resumeAsync(
cb: (exit: Exit<E, A>) => UIO<void>
): UIO<Fiber<E, A>>
): UIO<void>
}
8 changes: 3 additions & 5 deletions test/FIO.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -382,14 +382,12 @@ describe('FIO', () => {
assert.strictEqual(a.count, 1)
})

it('should return the same fiber', () => {
it('should return void', () => {
const actual = testRuntime().executeSync(
FIO.void().fork.chain(fiber =>
fiber.resumeAsync(FIO.void).map(_ => _ === fiber)
)
FIO.void().fork.chain(fiber => fiber.resumeAsync(FIO.void))
)

assert.isTrue(actual)
assert.isUndefined(actual)
})

it('should call with Exit.success', () => {
Expand Down

0 comments on commit 6988330

Please sign in to comment.