plugins-workspace icon indicating copy to clipboard operation
plugins-workspace copied to clipboard

refactor(store)!: more reworks

Open Legend-Master opened this issue 1 year ago • 6 comments

Follow up of #1550

Changes:

  • Disallow calling create_store when 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_store share 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

Legend-Master avatar Oct 02 '24 10:10 Legend-Master

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

github-actions[bot] avatar Oct 02 '24 10:10 github-actions[bot]

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?

lucasfernog avatar Oct 02 '24 10:10 lucasfernog

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

Legend-Master avatar Oct 02 '24 10:10 Legend-Master

I need to take a break, this thing is haunting me right now 😂

Legend-Master avatar Oct 02 '24 10:10 Legend-Master

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

Legend-Master avatar Oct 03 '24 02:10 Legend-Master

Did some basic testing and docs, should be ready for merge now

Legend-Master avatar Oct 03 '24 12:10 Legend-Master

@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.

lucasfernog avatar Oct 16 '24 18:10 lucasfernog

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 😂 )

lucasfernog avatar Oct 16 '24 18:10 lucasfernog

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

Legend-Master avatar Oct 17 '24 03:10 Legend-Master

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

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.

lucasfernog avatar Oct 17 '24 10:10 lucasfernog

@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?

lucasfernog avatar Oct 17 '24 10:10 lucasfernog

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.

amrbashir avatar Oct 17 '24 10:10 amrbashir

I.e. webview can't close resources from other webviews.

amrbashir avatar Oct 17 '24 10:10 amrbashir

yeah so fallback to the parent window or AppHandle, that should be good

lucasfernog avatar Oct 17 '24 10:10 lucasfernog

usually you shouldn't even know the RID if you can't also close the resource.. otherwise users can use a wrapper ID instead

lucasfernog avatar Oct 17 '24 10:10 lucasfernog

all good for us to merge and release this? @amrbashir and @Legend-Master no more breaking changes pls :D

lucasfernog avatar Oct 17 '24 11:10 lucasfernog

Except for close doesn't actually work right now, looks good to me

Legend-Master avatar Oct 17 '24 11:10 Legend-Master

we'll fix on the tauri side

lucasfernog avatar Oct 17 '24 11:10 lucasfernog