<R extends Request<any, any, any>>(): Constructor<R>Creates a constructor function for a specific Request type.
Example (Creating untagged request constructors)
import { Request } from "effect"
declare const UserProfile: unique symbol
declare const ProfileError: unique symbol
type UserProfile = typeof UserProfile
type ProfileError = typeof ProfileError
interface GetUserProfile extends Request.Request<UserProfile, ProfileError> {
readonly id: string
readonly includeSettings: boolean
}
const GetUserProfile = Request.of<GetUserProfile>()
const request = GetUserProfile({
id: "user-123",
includeSettings: true
})export const const of: <
R extends Request<any, any, any>
>() => Constructor<R>
Creates a constructor function for a specific Request type.
Example (Creating untagged request constructors)
import { Request } from "effect"
declare const UserProfile: unique symbol
declare const ProfileError: unique symbol
type UserProfile = typeof UserProfile
type ProfileError = typeof ProfileError
interface GetUserProfile extends Request.Request<UserProfile, ProfileError> {
readonly id: string
readonly includeSettings: boolean
}
const GetUserProfile = Request.of<GetUserProfile>()
const request = GetUserProfile({
id: "user-123",
includeSettings: true
})
of = <function (type parameter) R in <R extends Request<any, any, any>>(): Constructor<R>R extends interface Request<out A, out E = never, out R = never>A Request<A, E, R> is a request from a data source for a value of type A
that may fail with an E and have requirements of type R.
Example (Defining typed requests)
import type { Request } from "effect"
// Define a request that fetches a user by ID
interface GetUser extends Request.Request<string, Error> {
readonly _tag: "GetUser"
readonly id: number
}
// Define a request that fetches all users
interface GetAllUsers extends Request.Request<ReadonlyArray<string>, Error> {
readonly _tag: "GetAllUsers"
}
Request<any, any, any>>(): interface Constructor<R extends Request<any, any, any>, T extends keyof R = never>The constructor type returned by Request.of and Request.tagged.
Details
The constructor accepts the request's data fields, excluding request variance
fields and any fields already supplied by the constructor such as _tag, and
returns a value of the request type.
Example (Using generated request constructors)
import { Request } from "effect"
interface GetUser extends Request.Request<string, Error> {
readonly _tag: "GetUser"
readonly id: number
}
// Constructor type is used internally by Request.of() and Request.tagged()
const GetUser = Request.tagged<GetUser>("GetUser")
const userRequest = GetUser({ id: 123 })
Constructor<function (type parameter) R in <R extends Request<any, any, any>>(): Constructor<R>R> => (args: Types.VoidIfEmpty<
Types.Simplify<Omit<R, "~effect/Request">>
>
args) =>
var Object: ObjectConstructorProvides functionality common to all JavaScript objects.
Object.ObjectConstructor.assign<any, Types.VoidIfEmpty<Types.Simplify<Omit<R, "~effect/Request">>>>(target: any, source: Types.VoidIfEmpty<Types.Simplify<Omit<R, "~effect/Request">>>): any (+3 overloads)Copy the values of all of the enumerable own properties from one or more source objects to a
target object. Returns the target object.
assign(var Object: ObjectConstructorProvides functionality common to all JavaScript objects.
Object.ObjectConstructor.create(o: object | null): any (+1 overload)Creates an object that has the specified prototype or that has null prototype.
create(const RequestPrototype: Request<
any,
any,
any
>
Prototype used by Effect's request constructors.
Details
This low-level value provides the structural request marker for values
created by Request.of, Request.tagged, Request.Class, and
Request.TaggedClass. Most users should use those constructors instead of
interacting with the prototype directly.
RequestPrototype), args: Types.VoidIfEmpty<
Types.Simplify<Omit<R, "~effect/Request">>
>
args)