You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
So I just wanted to ask if Activejs could/would support:
Custom Persistent Storage
Something along the lines of providing an interface (get, set, observe...) which then a developer can provide and handle things like serialization, maybe even initial values etc. themselves. More specifically for example an IndexedDB wrapper might be interesting - here serialization for example would not have to (and should not) be done.
Storage Specification per Unit Type
Following the first point, it would be nice to specify this storage interface per unit (not sure if that's already/or even possible - since it needs to be set during configuration of Activejs I assume it isn't). This way one could for example save an "image blob list" unit in the more performant (and serialization-free) IndexedDB and some other smaller units (for example list of updogs) in eg. a synchronizable (and serialized) extension storage (browser.storage.sync this is specific to browser extensions).
Both of these could be done by not using Activejs' persistence, and instead listening on the object changes and saving them ourselves.
Would this observer approach instead be the recommended way to go?
Or would/should the above 2 ideas (or one of them) be in the scope of Activejs?
What do you think?
Generally asking anyone (inside and outside the Activejs team) who's interested
The text was updated successfully, but these errors were encountered:
1. Yes, you can change the default storage for persistent Units. You can change it to any storage interface (even custom implementation) that implements the Storage interface. You can find more information in the docs, here. However you can't handle the serialization outside of ActiveJS, as it's done internally. Regarding an IndexedDB wrapper, actually a very early implementation used the IndexedDB but it was hard to mix synchronous code with asynchronous IndexedDB, only way around that was to load all the stored state from the IndexedDB synchronously while blocking the whole application, because the persisted value is supposed to override the initialValue of the Unit. So IndexedDB was dropped in favor of localStorage and sessionStorage. You can still write a wrapper and provide it to ActiveJS, but it's probably not worth it.
2. As mentioned in the above point, asynchronous persistent storage is not feasible at the moment, as the Units are supposed to load the values synchronously. But thanks for mentioning it, because you can change the storage for specific Unit, I updated the docs, you can see it here.
In general, I'd advise to stick with synchronous storage.
Also, ActiveJS doesn't recommend storing non-serializable values in it, it might still work but there are no guarantees.
So I just wanted to ask if Activejs could/would support:
Custom Persistent Storage
Something along the lines of providing an interface (get, set, observe...) which then a developer can provide and handle things like serialization, maybe even initial values etc. themselves. More specifically for example an IndexedDB wrapper might be interesting - here serialization for example would not have to (and should not) be done.
Storage Specification per Unit Type
Following the first point, it would be nice to specify this storage interface per unit (not sure if that's already/or even possible - since it needs to be set during configuration of Activejs I assume it isn't). This way one could for example save an "image blob list" unit in the more performant (and serialization-free) IndexedDB and some other smaller units (for example list of updogs) in eg. a synchronizable (and serialized) extension storage (
browser.storage.sync
this is specific to browser extensions).Both of these could be done by not using Activejs' persistence, and instead listening on the object changes and saving them ourselves.
Would this observer approach instead be the recommended way to go?
Or would/should the above 2 ideas (or one of them) be in the scope of Activejs?
What do you think?
The text was updated successfully, but these errors were encountered: