Skip to content

Commit

Permalink
add Http.response.void helper, for creating a http request that retur…
Browse files Browse the repository at this point in the history
…ns void (#2565)
  • Loading branch information
tim-smart authored Apr 18, 2024
1 parent 0059a31 commit a3b0e6c
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/real-cups-repeat.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@effect/platform": patch
---

add Http.response.void helper, for creating a http request that returns void
10 changes: 10 additions & 0 deletions packages/platform/src/Http/ClientResponse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,16 @@ export const json: <E, R>(
effect: Effect.Effect<ClientResponse, E, R>
) => Effect.Effect<unknown, Error.ResponseError | E, Exclude<R, Scope.Scope>> = internal.json

const void_: <E, R>(effect: Effect.Effect<ClientResponse, E, R>) => Effect.Effect<void, E, Exclude<R, Scope.Scope>> =
internal.void_
export {
/**
* @since 1.0.0
* @category accessors
*/
void_ as void
}

/**
* @since 1.0.0
* @category accessors
Expand Down
4 changes: 4 additions & 0 deletions packages/platform/src/internal/http/clientResponse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,10 @@ export const urlParamsBody = <E, R>(effect: Effect.Effect<ClientResponse.ClientR
export const formData = <E, R>(effect: Effect.Effect<ClientResponse.ClientResponse, E, R>) =>
Effect.scoped(Effect.flatMap(effect, (_) => _.formData))

/** @internal */
export const void_ = <E, R>(effect: Effect.Effect<ClientResponse.ClientResponse, E, R>) =>
Effect.scoped(Effect.asVoid(effect))

/** @internal */
export const stream = <E, R>(effect: Effect.Effect<ClientResponse.ClientResponse, E, R>) =>
Stream.unwrapScoped(Effect.map(effect, (_) => _.stream))
Expand Down

0 comments on commit a3b0e6c

Please sign in to comment.