core: Added VirtualLazyFolder#36
Conversation
|
This wouldn't work because getFiles would return before the folder is populated. getFiles should await the promise, meaning the superclass needs to be adjusted to be async instead, and all call sites need to be adjusted also to await the promise getFiles, or any method that calls getFiles, returns. |
62b4e68 to
0c8b93f
Compare
|
Added loadContent() to VirtualFolder which does nothing, overridden in VirtualLazyFolder to await and cache the onPopulate() promise. getFilesAsync() and getSubFoldersAsync() now await loadContent() before returning, which allows callers that need guaranteed content to await them instead of relying on the update event. |
|
Added Tests + small bugfix |
|
I think it would be cleaner to keep the VirtualFolder classs as is and to keep the lazy loading logic in the VirtualLazyFolder. |
|
This would mean that you would have to type check the folder type every time you want to use asynchronous loading, which i think would be annoying. |
Added VirtualLazyFolder class with a onPopulate() function which the user can override.