You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently each time we call the async function text() or arrayBuffer() the data are reloaded (refetch if it is coming from a web server).
We could therefore have an internal cache system.
One way would be to create a class CachedFileCollectionItem that is wrapping FileCollectionItem.
At first CachedFileCollectionItem would exactly contain the same properties / methods as FileCollectionItem. However we would change the method once the data has been fetched.
classCachedFileCollectionItem{constructor(fileCollectionItem){this.fileCollectionItem=fileCollectionItem;}asynctext(){returnthis.textCache=this.textCache||this.fileCollectionItem.text();}asyncarrayBuffer(){returnthis.arrayBufferCache=this.arrayBufferCache||this.fileCollectionItem.arrayBufferCache();}asyncstream(){returnthis.fileCollectionItem.stream();// no cache for stream !}getlastModified(){returnthis.fileCollectionItem.lastModified};getname(){returnthis.fileCollectionItem.name};getrelativePath(){returnthis.fileCollectionItem.relativePath};getsize(){returnthis.fileCollectionItem.size};}
The files in FileCollection would therefore become an array of CachedFileCollectionItem readonly files: CachedFileCollectionItem[];
The text was updated successfully, but these errors were encountered:
Currently each time we call the async function
text()
orarrayBuffer()
the data are reloaded (refetch if it is coming from a web server).We could therefore have an internal cache system.
One way would be to create a class
CachedFileCollectionItem
that is wrappingFileCollectionItem
.At first
CachedFileCollectionItem
would exactly contain the same properties / methods as FileCollectionItem. However we would change the method once the data has been fetched.The
files
in FileCollection would therefore become an array ofCachedFileCollectionItem
readonly files: CachedFileCollectionItem[];
The text was updated successfully, but these errors were encountered: