resourcerer 1.0.6 → 1.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/request.js +4 -0
- package/lib/resourcerer.js +7 -0
- package/package.json +1 -1
package/lib/request.js
CHANGED
|
@@ -93,6 +93,10 @@ export default (key, Model, options={}) => {
|
|
|
93
93
|
ModelCache.put(key, model, options.component);
|
|
94
94
|
resolve([model]);
|
|
95
95
|
}
|
|
96
|
+
// this block normally will not get invoked because previous-cached resources will bypass
|
|
97
|
+
// the request module to avoid the async Promise tick. this will still get called for some
|
|
98
|
+
// unconventional resource loading such as prefetch requests that are cached, both from the
|
|
99
|
+
// prefetch module and from the `prefetches` resource config property
|
|
96
100
|
} else {
|
|
97
101
|
// this will cancel any in-flight timeouts and add the component
|
|
98
102
|
// to the list of components using the resource
|
package/lib/resourcerer.js
CHANGED
|
@@ -163,6 +163,13 @@ export const useResources = (getResources, props) => {
|
|
|
163
163
|
setModels(modelAggregator(pendingResources.concat(loadedResources).filter(withoutPrefetch)));
|
|
164
164
|
}
|
|
165
165
|
|
|
166
|
+
// because we don't go through the request module for normal-flow resources that are cached,
|
|
167
|
+
// we need to re-register this component with the resource. this will also clear any timeouts
|
|
168
|
+
// for removing the resource.
|
|
169
|
+
loadedResources.map(
|
|
170
|
+
([, config]) => ModelCache.register(getCacheKey(config), componentRef.current)
|
|
171
|
+
);
|
|
172
|
+
|
|
166
173
|
// NOTE: changing this to resourcesToFetch causes some inexplicable bugs around cached resources
|
|
167
174
|
// and a UI that wouldn't update. so this is kept as resourcesToUpdate and fetchResources is
|
|
168
175
|
// given resourcesToFetch. Because we are still only fetching resourcesToFetch and because any
|