TypeScript error: Type 'void' is not assignable to type Promise<Note[]>

There is a fairly subtle yet deadly race condition here, which is why I suggest never using storage for in-app communication, only for persistence across app restarts.

In other words, you should only call storage.get(), directly or indirectly, once, at app startup. If getAllNotes() is to remain part of the public interface of NoteServices, it should not be reading from storage.

The problem is that storage writes themselves are not synchronous, so imagine this situation: a modal dialog triggers a call to saveNote() and then closes itself, which results in a list of notes page calling 'getAllnotes()` to refresh its list of notes. You have no guarantee as to whether or not the freshly saved note will be there. Sometimes it will, sometimes it won’t.

It is theoretically possible to have saveNote() return a future, and to require all clients of NoteServices understand this situation, or to create an internal spinlock inside NoteServices. I have tried a bunch of things along these lines, and have yet to find one that is not both overly complex and still brittle and error-prone.

So I have decided that it is cleanest and safest to use “app exiting and restarting” as the mother of all synchronization points when dealing with storage, which means that the only time an app can read from storage is at startup.