IndexedDB

Another item on the TODO list ticked off, IndexedDB is now working in the browser by using Holster({indexedDB: true}). Thankfully the GunDB code was pretty easy to re-use for this! I've kept it opt-in to use browser storage, as Holster currently works fine with server only storage and I'd like to keep both working.

I also missed an update to the examples folder I could've made earlier. It previously didn't try to run both Holster API updates at the same time due to the shared context, but now that's working it's fine to make the two updates occur at random times similar to wire.js. The main difference now being that index.js doesn't set state values on properties, so the value that is fetched at the end is whichever update happened last.

Listening to updates

I finally finished adding event listeners to the Holster API, and decided to stick with GunDB's idea of on and off functions.

It took me longer than I expected because on callbacks are long-lived, so the context chain I was using needed to stick around somehow. I also realised that I couldn't do much else once there was an event listener because there was only one context. Or if there was another request the on callback would lose what it was referring to when called.

This meant that the API need to store each context while it was being used, and only remove them when a callback had finished. This took a few attempts, as holster.get().get() previously made sense, but having another request start a new holster.get() meant the two requests couldn't be distinguished from each other and would overwrite the single context available. The solution ended up being that each holster.get() starts a new context, and to differentiate new requests I've added then() to provide the chaining API.

Now Holster can do queries such as:
holster.get("hello").then("world!").on(console.log)

// Which will get called by this update.
holster.get("hello").then("world!").put("update", console.log)
I figured that was enough API changes to add a new page to the Github Wiki, so I've also added a new API page with more details.