refactor(store)!: more reworks
Follow up of #1550
Changes:
- Disallow calling
create_storewhen there're still active stores with the same path alive - Save and cancel pending auto save on drop
- Use absolute path as store's key, fix #984
New features:
- Add
getStore/get_storeshare stores across js and rust side - Add default (de)serialize functions settings
- Allow js to use pre-stored (de)serialize functions
- Add back lazy store (implemented in js)
Default changes:
- Share store to resource table by default
- Enable auto save with 100ms debounce time by default
- Use pretty json by default, close #1690
Package Changes Through 8e71393946d4086395e4db1979777e4bec9cfcb7
There are 10 changes which include dialog with patch, dialog-js with patch, positioner with patch, positioner-js with patch, http with patch, http-js with patch, shell with patch, shell-js with patch, store-js with minor, store with minor
Planned Package Versions
The following package releases are the planned based on the context of changes in this pull request.
| package | current | next |
|---|---|---|
| api-example | 2.0.2 | 2.0.3 |
| api-example-js | 2.0.0 | 2.0.1 |
| dialog | 2.0.1 | 2.0.2 |
| dialog-js | 2.0.0 | 2.0.1 |
| http | 2.0.1 | 2.0.2 |
| http-js | 2.0.0 | 2.0.1 |
| positioner | 2.0.1 | 2.0.2 |
| positioner-js | 2.0.0 | 2.0.1 |
| shell | 2.0.1 | 2.0.2 |
| shell-js | 2.0.0 | 2.0.1 |
| store | 2.0.1 | 2.1.0 |
| store-js | 2.0.0 | 2.1.0 |
Add another change file through the GitHub UI by following this link.
Read about change files or the docs at github.com/jbolda/covector
can't we automatically share the store? like always make it available in the same collection, so a call from another language would pick it up anyway?
Yeah I was thinking about it, but that means you'll need to always preserve that store, sometimes you might just want to read the data from it and forget about it, maybe share/preserve it by default, and add a close function or something
I need to take a break, this thing is haunting me right now 😂
Note: don't merge it yet, I didn't have the time to test and write the docs yet, got some other things to handle, might be able get back on this tomorrow or something like that
Did some basic testing and docs, should be ready for merge now
@amrbashir @Legend-Master i've removed the rust's create from the StoreBuilder and renamed new_or_existing to build.
I also renamed the load function to reload just to be able to call the newOrExisting function load. Let me know what you think.
if you're still not happy with this name then we can just agree we're all awful at this and we'll never agree, and remove the Store class and just go with the LazyStore as default (that way we can just the constructor instead of having to name a static function 😂 )
To be honest, I still find create to be very confusing, I don't think anyone will expect it to mean open an empty store in the rust side without loading from disk while load gets the opened store or create a new store but also loads it
To be honest, I still find
createto be very confusing, I don't think anyone will expect it to mean open an empty store in the rust side without loading from disk whileloadgets the opened store or create a new store but also loads it
I've removed the create function from the Rust side, maybe we do the same on the JS side too. I'll push this change for you to take a look.
@amrbashir i wanted to use the Resource class close() method instead of creating a dedicated one but I can't because we're using the AppHandle resource table and not the Webview one.. should the resources plugin allow me to configure which table i'm referring to? or fallback to other tables?
I was thinking something similar but Idk if the auditors will approve, maybe if we allow only closing resources from the same webview, or the same window or the app handle, It should be fine then.
I.e. webview can't close resources from other webviews.
yeah so fallback to the parent window or AppHandle, that should be good
usually you shouldn't even know the RID if you can't also close the resource.. otherwise users can use a wrapper ID instead
all good for us to merge and release this? @amrbashir and @Legend-Master no more breaking changes pls :D
Except for close doesn't actually work right now, looks good to me
we'll fix on the tauri side