TJSDocumentProperty Prototype

So I implemented a prototype of a custom store implementation that wraps a TJSDocument instance that allows dynamic store access to property accessors. TJSDocumentProperty is a complete Writable instance allowing update to be used when more complex modification is required for the underlying property; IE pushing to an array or modifying a nested object. I included TJSDocumentProperty as an attachment to this post. Also is a demo Svelte component that can be copied to BasicDocAppShell in essential-svelte-esm. This demo is what is shown in the video preview. Note: That I'm using the internal 0.2.0 pre-release code and likely there are modifications necessary to get this to work with 0.1.3 which likely has slightly different context callback data. Also note that the core v12 changes for renderContext are not normalized yet. TJSDocument will receive a facelift for the 0.2.0 release and quite likely a solution related to TJSDocumentProperty will be available built-in to TJSDocument I'd be glad to get some feedback and certainly can help adjust this code to the current 0.1.3 release, but it clearly shows what is possible. Here is the video preview: https://www.youtube.com/watch?v=PPW7opFlS90
TyphonJS
YouTube
TJSDocumentProperty Prototype
This video shows off a new separate prototype implementation for Foundry document property accessor access with a connected TJSDocument instance. This separate class TJSDocumentProperty is a custom store that wraps a TJSDocument instance and buffers updates through the connected document. It can be bound as a store to input elements and provid...
8 Replies
Vauxs
Vauxs5mo ago
The #handleDocUpdate V12 shim uses context.renderData to retrieve the new value, when renderData only includes new stuff instead of the entire object. Replacing context.renderData with this.#doc?.get() in that section (logged "#handleDocUpdate - D") fixes the issue As far as I have tested
Vauxs
Vauxs5mo ago
TyphonJS (Michael)
TyphonJS (Michael)OP5mo ago
Exactly.. Though the idea is to minimize the updates if the given property is not actually updated. Swapping out to always update regardless of property could be a problem with lots of properties. I did see the renderData problem just after I posted the code. I'll likely come up with a good solution when I get around to finishing TJSDocument improvements.
Vauxs
Vauxs5mo ago
yeah looking at it there is one more important thing to implement which is the removal of properties Looking at unsetFlag its not so difficult I guess but I do need to make an explicit remove function for it
TyphonJS (Michael)
TyphonJS (Michael)OP5mo ago
You should make that call directly on the document.
Vauxs
Vauxs5mo ago
basically update({"-=key": null})
TyphonJS (Michael)
TyphonJS (Michael)OP5mo ago
I'll be making a managed version of all of this similar to the reactive embedded collection API in TJSDocument. Probably will be able to get the backing TJSDocument instance from the property store, but the API is going to be something like this: tjsDocument.accessors.get('flags.my-thing.foo'); You can pass around the TJSDocument and share property accessors across components.
Vauxs
Vauxs5mo ago
... I think this would have fixed everything since the beginning It works now just, plainly :stress: well at least its solved :clownWokeJoy:
Want results from more Discord servers?
Add your server