NetworkManager orchestrates asynchronous fetches. By keeping track of all in-flight requests it is able to dedupe identical requests if they are made using the throttle flag.
NetworkManager implements Manager
constructor(dataExpiryLength = 60000, errorExpiryLength = 1000)
Arguments represent the default time (in miliseconds) before a resource is considered 'stale'.
Will initiate network request and then dispatch upon completion.
Marks request as complete.
handleFetch(fetchAction, dispatch, controller)
Called when middleware intercepts 'rest-hooks/fetch' action.
Will then start a promise for a key and potentially start the network fetch.
Uses throttle only when instructed by action meta. This is valuable for ensures mutation requests always go through.
Called when middleware intercepts a receive action.
Will resolve the promise associated with receive key.
Ensures only one request for a given key is in flight at any time
Uses key to either retrieve in-flight promise, or if not create a new promise and call fetch.
Timestamp when entire store was last reset
Clear promise state for a given key
Ensures all promises are completed by rejecting remaining