Skip to content

Commit

Permalink
fix(managed): fix issue with releasing of resource happens multiple t…
Browse files Browse the repository at this point in the history
…imes
  • Loading branch information
tusharmath committed Oct 20, 2019
1 parent d5becbb commit bfddfe5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
10 changes: 5 additions & 5 deletions src/main/Managed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,12 @@ export class Managed<E1, A1, R1> {
acquire: FIO<E1, A1, R1>,
release: (a: A1) => FIO<never, void, R2>
): Managed<E1, A1, R1 & R2> {
return Managed.of(
acquire
.map(a1 =>
Reservation.of(FIO.of(a1).addEnv<R2>(), release(a1).addEnv<R1>())
return Managed.of<E1, A1, R1 & R2>(
acquire.chain(a1 =>
release(a1).once.map(r =>
Reservation.of(FIO.of(a1).addEnv<R1>(), r.addEnv<R2>())
)
.addEnv()
)
)
}

Expand Down
2 changes: 1 addition & 1 deletion test/Managed.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ describe('Managed', () => {
assert.ok(r.isReleased)
})

it.skip('should release only once', () => {
it('should release only once', () => {
const r = Resource()
const runtime = testRuntime()

Expand Down

0 comments on commit bfddfe5

Please sign in to comment.