Command
import { Command } from "@hyper-fetch/core"
Description
Fetch command it is designed to prepare the necessary setup to execute the request to the server. We can setup basic options for example endpoint, method, headers and advanced settings like cache, invalidation patterns, concurrency, retries and much, much more.
We should not use this class directly in the standard development flow. We can initialize it using the
createCommand
method on the Builder class.
Defined in command/command.ts:33
Parameters
Name | Details |
---|---|
builder
|
|
commandOptions
|
|
commandDump
|
|
dataMapper
|
|
Properties
commandDump
commandDump
Description
Defined in command/command.ts:78
Type
CommandCurrentType<ResponseType, RequestDataType, QueryParamsType, GlobalErrorType | LocalErrorType, EndpointType, ClientOptions, MappedData>
commandOptions
commandOptions
Description
Defined in command/command.ts:77
Type
CommandConfig<EndpointType, ClientOptions>
data
data
Description
Defined in command/command.ts:51
Type
MappedData extends never ? RequestDataType : MappedData
Methods
dataMapper()
dataMapper()
Description
Defined in command/command.ts:89
Return
(data: RequestDataType) => MappedData
exec()
exec()
Description
Method to use the command WITHOUT adding it to cache and queues. This mean it will make simple request without queue side effects.
Defined in command/command.ts:395
Return
Promise<[Data | null, Error | null, HttpStatus]>
send()
send()
Description
Method used to perform requests with usage of cache and queues
Defined in command/command.ts:444
Return
Promise<[Data | null, Error | null, HttpStatus]>
abort()
abort()
Preview
abort()
Description
Defined in command/command.ts:379
Return
Command<ResponseType, RequestDataType, QueryParamsType, GlobalErrorType, LocalErrorType, EndpointType, ClientOptions, HasData, HasParams, HasQuery, MappedData>
clone()
clone()
Preview
clone<D, P, Q, NewMappedData>(options, mapper)
Description
Defined in command/command.ts:307
Parameters
Name | Details |
---|---|
options
|
|
mapper
|
|
Return
Command<ResponseType, RequestDataType, QueryParamsType, GlobalErrorType, LocalErrorType, EndpointType, ClientOptions, D, P, Q, NewMappedData>
dump()
dump()
Preview
dump()
Description
Defined in command/command.ts:256
Return
{
abortKey: string;
auth: boolean;
cache: boolean;
cacheKey: string;
cacheTime: number;
cancelable: boolean;
commandOptions: {
abortKey: string;
auth: boolean;
cache: boolean;
cacheKey: string;
cacheTime: number;
cancelable: boolean;
deduplicate: boolean;
deduplicateTime: number;
disableRequestInterceptors: boolean;
disableResponseInterceptors: boolean;
effectKey: string;
endpoint: GenericEndpoint;
garbageCollection: number;
headers: HeadersInit;
method: GET | POST | PUT | PATCH | DELETE;
offline: boolean;
options: ClientOptions;
queueKey: string;
queued: boolean;
retry: number;
retryTime: number;
};
data: MappedData extends never ? RequestDataType : MappedData | \null\ | \undefined\;
deduplicate: boolean;
deduplicateTime: number;
disableRequestInterceptors: boolean | undefined;
disableResponseInterceptors: boolean | undefined;
effectKey: string;
endpoint: string;
garbageCollection: number;
headers: HeadersInit;
method: GET | POST | PUT | PATCH | DELETE;
offline: boolean;
options: ClientOptions | T extends Command<any, any, any, any, any, any, infer O, any, any, any, any> ? O : never;
params: Params | \null\ | \undefined\;
queryParams: QueryParamsType | \null\ | \undefined\;
queueKey: string;
queued: boolean;
retry: number;
retryTime: number;
updatedAbortKey: boolean;
updatedCacheKey: boolean;
updatedEffectKey: boolean;
updatedQueueKey: boolean;
used: boolean;
}
setAbortKey()
setAbortKey()
Preview
setAbortKey(abortKey)
Description
Defined in command/command.ts:200
Parameters
Name | Details |
---|---|
abortKey
|
|
Return
Command<ResponseType, RequestDataType, QueryParamsType, GlobalErrorType, LocalErrorType, EndpointType, ClientOptions, HasData, HasParams, HasQuery, MappedData>
setAuth()
setAuth()
Preview
setAuth(auth)
Description
Defined in command/command.ts:147
Parameters
Name | Details |
---|---|
auth
|
|
Return
Command<ResponseType, RequestDataType, QueryParamsType, GlobalErrorType, LocalErrorType, EndpointType, ClientOptions, HasData, HasParams, HasQuery, MappedData>
setCache()
setCache()
Preview
setCache(cache)
Description
Defined in command/command.ts:188
Parameters
Name | Details |
---|---|
cache
|
|
Return
Command<ResponseType, RequestDataType, QueryParamsType, GlobalErrorType, LocalErrorType, EndpointType, ClientOptions, HasData, HasParams, HasQuery, MappedData>
setCacheKey()
setCacheKey()
Preview
setCacheKey(cacheKey)
Description
Defined in command/command.ts:205
Parameters
Name | Details |
---|---|
cacheKey
|
|
Return
Command<ResponseType, RequestDataType, QueryParamsType, GlobalErrorType, LocalErrorType, EndpointType, ClientOptions, HasData, HasParams, HasQuery, MappedData>
setCacheTime()
setCacheTime()
Preview
setCacheTime(cacheTime)
Description
Defined in command/command.ts:192
Parameters
Name | Details |
---|---|
cacheTime
|
|
Return
Command<ResponseType, RequestDataType, QueryParamsType, GlobalErrorType, LocalErrorType, EndpointType, ClientOptions, HasData, HasParams, HasQuery, MappedData>
setCancelable()
setCancelable()
Preview
setCancelable(cancelable)
Description
Defined in command/command.ts:170
Parameters
Name | Details |
---|---|
cancelable
|
|
Return
Command<ResponseType, RequestDataType, QueryParamsType, GlobalErrorType, LocalErrorType, EndpointType, ClientOptions, HasData, HasParams, HasQuery, MappedData>
setData()
setData()
Preview
setData<D>(data)
Description
Defined in command/command.ts:155
Parameters
Name | Details |
---|---|
data
|
|
Return
Command<ResponseType, RequestDataType, QueryParamsType, GlobalErrorType, LocalErrorType, EndpointType, ClientOptions, D extends null ? false : true, HasParams, HasQuery, MappedData>
setDataMapper()
setDataMapper()
Preview
setDataMapper<DataMapper>(mapper)
Description
Defined in command/command.ts:236
Parameters
Name | Details |
---|---|
mapper
|
|
Return
Command<ResponseType, RequestDataType, QueryParamsType, GlobalErrorType, LocalErrorType, EndpointType, ClientOptions, HasData, HasParams, HasQuery, MappedData>
setDeduplicate()
setDeduplicate()
Preview
setDeduplicate(deduplicate)
Description
Defined in command/command.ts:220
Parameters
Name | Details |
---|---|
deduplicate
|
|
Return
Command<ResponseType, RequestDataType, QueryParamsType, GlobalErrorType, LocalErrorType, EndpointType, ClientOptions, HasData, HasParams, HasQuery, MappedData>
setDeduplicateTime()
setDeduplicateTime()
Preview
setDeduplicateTime(deduplicateTime)
Description
Defined in command/command.ts:224
Parameters
Name | Details |
---|---|
deduplicateTime
|
|
Return
Command<ResponseType, RequestDataType, QueryParamsType, GlobalErrorType, LocalErrorType, EndpointType, ClientOptions, HasData, HasParams, HasQuery, MappedData>
setEffectKey()
setEffectKey()
Preview
setEffectKey(effectKey)
Description
Defined in command/command.ts:215
Parameters
Name | Details |
---|---|
effectKey
|
|
Return
Command<ResponseType, RequestDataType, QueryParamsType, GlobalErrorType, LocalErrorType, EndpointType, ClientOptions, HasData, HasParams, HasQuery, MappedData>
setGarbageCollection()
setGarbageCollection()
Preview
setGarbageCollection(garbageCollection)
Description
Defined in command/command.ts:182
Parameters
Name | Details |
---|---|
garbageCollection
|
|
Return
Command<ResponseType, RequestDataType, QueryParamsType, GlobalErrorType, LocalErrorType, EndpointType, ClientOptions, HasData, HasParams, HasQuery, MappedData>
setHeaders()
setHeaders()
Preview
setHeaders(headers)
Description
Defined in command/command.ts:143
Parameters
Name | Details |
---|---|
headers
|
|
Return
Command<ResponseType, RequestDataType, QueryParamsType, GlobalErrorType, LocalErrorType, EndpointType, ClientOptions, HasData, HasParams, HasQuery, MappedData>
setOffline()
setOffline()
Preview
setOffline(offline)
Description
Defined in command/command.ts:232
Parameters
Name | Details |
---|---|
offline
|
|
Return
Command<ResponseType, RequestDataType, QueryParamsType, GlobalErrorType, LocalErrorType, EndpointType, ClientOptions, HasData, HasParams, HasQuery, MappedData>
setOptions()
setOptions()
Preview
setOptions(options)
Description
Defined in command/command.ts:166
Parameters
Name | Details |
---|---|
options
|
|
Return
Command<ResponseType, RequestDataType, QueryParamsType, GlobalErrorType, LocalErrorType, EndpointType, ClientOptions, HasData, HasParams, true, MappedData>
setParams()
setParams()
Preview
setParams<P>(params)
Description
Defined in command/command.ts:151
Parameters
Name | Details |
---|---|
params
|
|
Return
Command<ResponseType, RequestDataType, QueryParamsType, GlobalErrorType, LocalErrorType, EndpointType, ClientOptions, HasData, P extends null ? false : true, HasQuery, MappedData>
setQueryParams()
setQueryParams()
Preview
setQueryParams(queryParams)
Description
Defined in command/command.ts:162
Parameters
Name | Details |
---|---|
queryParams
|
|
Return
Command<ResponseType, RequestDataType, QueryParamsType, GlobalErrorType, LocalErrorType, EndpointType, ClientOptions, HasData, HasParams, true, MappedData>
setQueueKey()
setQueueKey()
Preview
setQueueKey(queueKey)
Description
Defined in command/command.ts:210
Parameters
Name | Details |
---|---|
queueKey
|
|
Return
Command<ResponseType, RequestDataType, QueryParamsType, GlobalErrorType, LocalErrorType, EndpointType, ClientOptions, HasData, HasParams, HasQuery, MappedData>
setQueued()
setQueued()
Preview
setQueued(queued)
Description
Defined in command/command.ts:196
Parameters
Name | Details |
---|---|
queued
|
|
Return
Command<ResponseType, RequestDataType, QueryParamsType, GlobalErrorType, LocalErrorType, EndpointType, ClientOptions, HasData, HasParams, HasQuery, MappedData>
setRetry()
setRetry()
Preview
setRetry(retry)
Description
Defined in command/command.ts:174
Parameters
Name | Details |
---|---|
retry
|
|
Return
Command<ResponseType, RequestDataType, QueryParamsType, GlobalErrorType, LocalErrorType, EndpointType, ClientOptions, HasData, HasParams, HasQuery, MappedData>
setRetryTime()
setRetryTime()
Preview
setRetryTime(retryTime)
Description
Defined in command/command.ts:178
Parameters
Name | Details |
---|---|
retryTime
|
|
Return
Command<ResponseType, RequestDataType, QueryParamsType, GlobalErrorType, LocalErrorType, EndpointType, ClientOptions, HasData, HasParams, HasQuery, MappedData>