You really have 2 methods, get and set to be concerned with.
set is called when the state changes, and you can see in the cookieProvider that they set a cookie for the state of the object. You could add an AJAX call within the set method to persist to DB, save to a localStorage store, and sync the localstorage store,save to memory store and sync that with DB. The get method you override should read from whereever you decide to save the information to. THe constructor should load the state from the database, which would be in the same spot as