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:32
Parameters
Name | Details |
---|---|
builder
|
|
commandOptions
|
|
commandDump
|
|
dataMapper
|
|
Properties
commandDump
commandDump
Description
Defined in command/command.ts:77
Type
CommandCurrentType<ResponseType, RequestDataType, QueryParamsType, GlobalErrorType | LocalErrorType, EndpointType, ClientOptions, MappedData>
commandOptions
commandOptions
Description
Defined in command/command.ts:76
Type
CommandConfig<EndpointType, ClientOptions>
data
data
Description
Defined in command/command.ts:50
Type
MappedData extends undefined ? RequestDataType : MappedData
Methods
dataMapper()
dataMapper()
Description
Defined in command/command.ts:88
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:394
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:443
Return
Promise<[Data | null, Error | null, HttpStatus]>
abort()
abort()
Preview
abort()
Description
Defined in command/command.ts:378
Return
Command<ResponseType, RequestDataType, QueryParamsType, GlobalErrorType, LocalErrorType, EndpointType, ClientOptions, HasData, HasParams, HasQuery, MappedData>
clone()
clone()
Preview
clone<D, P, Q, MapperData>(options, mapper)
Description
Defined in command/command.ts:306
Parameters
Name | Details |
---|---|
options
|
|
mapper
|
|
Return
Command<ResponseType, RequestDataType, QueryParamsType, GlobalErrorType, LocalErrorType, EndpointType, ClientOptions, D, P, Q, MapperData>
dump()
dump()
Preview
dump()
Description
Defined in command/command.ts:255
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 undefined ? 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> ? 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:199
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:146
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:187
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:204
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:191
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:169
Parameters
Name | Details |
---|---|
cancelable
|
|
Return
Command<ResponseType, RequestDataType, QueryParamsType, GlobalErrorType, LocalErrorType, EndpointType, ClientOptions, HasData, HasParams, HasQuery, MappedData>
setData()
setData()
Preview
setData(data)
Description
Defined in command/command.ts:154
Parameters
Name | Details |
---|---|
data
|
|
Return
Command<ResponseType, RequestDataType, QueryParamsType, GlobalErrorType, LocalErrorType, EndpointType, ClientOptions, true, HasParams, HasQuery, MappedData>
setDataMapper()
setDataMapper()
Preview
setDataMapper<DataMapper>(mapper)
Description
Defined in command/command.ts:235
Parameters
Name | Details |
---|---|
mapper
|
|
Return
Command<ResponseType, RequestDataType, QueryParamsType, GlobalErrorType, LocalErrorType, EndpointType, ClientOptions, HasData, HasParams, HasQuery, DataMapper>
setDeduplicate()
setDeduplicate()
Preview
setDeduplicate(deduplicate)
Description
Defined in command/command.ts:219
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:223
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:214
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:181
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:142
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:231
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:165
Parameters
Name | Details |
---|---|
options
|
|
Return
Command<ResponseType, RequestDataType, QueryParamsType, GlobalErrorType, LocalErrorType, EndpointType, ClientOptions, HasData, HasParams, true, MappedData>
setParams()
setParams()
Preview
setParams(params)
Description
Defined in command/command.ts:150
Parameters
Name | Details |
---|---|
params
|
|
Return
Command<ResponseType, RequestDataType, QueryParamsType, GlobalErrorType, LocalErrorType, EndpointType, ClientOptions, HasData, true, HasQuery, MappedData>
setQueryParams()
setQueryParams()
Preview
setQueryParams(queryParams)
Description
Defined in command/command.ts:161
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:209
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:195
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:173
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:177
Parameters
Name | Details |
---|---|
retryTime
|
|
Return
Command<ResponseType, RequestDataType, QueryParamsType, GlobalErrorType, LocalErrorType, EndpointType, ClientOptions, HasData, HasParams, HasQuery, MappedData>