Local storage as Observable Service
Jul 23, 2020 10:08 · 106 words · 1 minute read
A quick and simple example of creating a stream for your entire local storage. We will use an Observable based service.
Our service holds _entireStorage$:BehaviorSubject<Map<string, string>>
subject that we will subscribe all users of this service to in constructor. This will handle multicasting. Other than that we have 3 very simple methods - adding and removing of items from local storage (these are public and can be used in components / directives using this service) and _allStorage
that basicaly gathers entire storage into a map. This map is the data we store in our subject.