Explanation of commit/load awaiting
Closed this issue · 2 comments
awaitLoading()
Required at start of your program to await file reading
Why just not to read file blocking when class instance created?
The files with data are usually small, but for example if your android app runs on low version and you are using object
to initialize storage, you can get freeze at lazy initialization.
Firstly that let you know where your app can be freezed, so better to freeze it in onCreate (because usually it takes some time to start activity) than when a button clicked
Useless in browser JS, because there localStorage
uses as storage for data. (blocking and lightweight operation)
awaitLastCommit()
Required at application finish to await saving coroutine if it exists
Useless in infinity-running apps (or lifecycle-dependent) such as Android App, IOS app, Web server, JS Frontend.
I found it required only in colsole apps
TODO: create blocking loading awaiting when first time getting/setting variable. That should not affect on perfomance (especially when it is server or js frontend), because the files are really small, but it is still recommended to use awaitLoading on android & ios