redux-data-service > FetchRecordEpic
Requests an individual item using the given api adapter.
- the item is then deserialized with the given serializer
- and normalized into the proper IModel instance with the given mapper.
Finally, a PUSH_RECORD
action is emitted to add the IModel
instance to its redux store.
Note that the item will not be reloaded if it already exists in its redux store, unless action.meta.forceReload
is true
.
If the library configuration setting coalesceFindRequests
is true
, it will accumulate these requests for coalesceBufferTime
(default 50ms) before dispatching a FETCH_ALL
action with the requested ids
as query params if more than one item is requested during that period.
FetchRecordEpic
⊕ new FetchRecordEpic(context: IContext): FetchRecordEpic
Defined in Services/DataService/Epics/FetchRecordEpic.ts:46
Parameters:
Name | Type |
---|---|
context | IContext |
Returns: FetchRecordEpic
● bufferedObservable: any
Defined in Services/DataService/Epics/FetchRecordEpic.ts:46
● context: IContext
Defined in Services/DataService/Epics/FetchRecordEpic.ts:45
▸ createBufferObservable(id: string
): Observable
<any
>
Defined in Services/DataService/Epics/FetchRecordEpic.ts:72
This method creates the buffer Observable for use in the performBufferRequest
function. There is an N millisecond period over which results are coalesced if the coalesceBufferTime
constant is specified in the configuration (its default is 50 ms). If there is only one item, the standard loadRecord
function is called.
Parameters:
Name | Type |
---|---|
id | string |
Returns: Observable
<any
>
▸ execute(action$: ActionsObservable
<any
>, store: Store
<IDataServiceStateRecord<any
>>): Observable
<IAction<any
>>
Implementation of IEpic.execute
Defined in Services/DataService/Epics/FetchRecordEpic.ts:103
Parameters:
Name | Type |
---|---|
action$ | ActionsObservable <any > |
store | Store <IDataServiceStateRecord<any >> |
Returns: Observable
<IAction<any
>>
▸ loadRecord(id: string
, progressSubscriber?: Subscriber
<any
>): Observable
<IAction<any
>>
Defined in Services/DataService/Epics/FetchRecordEpic.ts:55
Helper method that fetches, deserializes, and normalizes the item from the API
Parameters:
Name | Type |
---|---|
id | string |
Optional progressSubscriber |
Subscriber <any > |
Returns: Observable
<IAction<any
>>
▸ performBufferedRequest(id: string
): Observable
<any
>
Defined in Services/DataService/Epics/FetchRecordEpic.ts:90
Checks the cache for a buffered Observable that matches the context. If the buffer doesn't exist, it is created, and prepared to be disposed of at the end of its lifetime. Either the buffered Observable is returned or the current id is added to the given buffered Observable and the Observable is completed
Parameters:
Name | Type |
---|---|
id | string |
Returns: Observable
<any
>