Implementing a distributed Notes app with Firebase and SwiftUI
One of the strongest features of Firebase is its distributed database capabilities. Since its first release, the possibility of having a distributed database in the cloud gave mobile developers a simple way of handling secure persistent storage in the cloud.
Firebase offers two types of databases:
- Realtime Database, which is the original one
- Cloud Firestore, which is a new and more powerful implementation
For this recipe, we are going to use Cloud Firestore. It not only allows apps to save data in the repository, but it also sends events when it is updated by another client, permitting your app to react to these changes in a seamless way. This asynchronous feature works very well with SwiftUI.
In this recipe, we are going to implement a simplified version of the default Notes app. In this app, we can save our notes in a Firestore collection, without being concerned with explicitly saving the notes...