UNPKG

@td-design/rn-hooks

Version:

从ahooks里面抽取的一些在rn项目里可以使用的hooks。提高开发效率

21 lines (19 loc) 632 B
var cachePromise = new Map(); var getCachePromise = function (cacheKey) { return cachePromise.get(cacheKey); }; var setCachePromise = function (cacheKey, promise) { // Should cache the same promise, cannot be promise.finally // Because the promise.finally will change the reference of the promise cachePromise.set(cacheKey, promise); // no use promise.finally for compatibility promise .then(function (res) { cachePromise.delete(cacheKey); return res; }) .catch(function () { cachePromise.delete(cacheKey); }); }; export { getCachePromise, setCachePromise };