Integrating external mutable objects
Hey! I'm writing a system for FoundryVTT. It stores relevant game data in Documents, large mutable objects. It also provides Hooks, which are just callbacks, whenever anything happens or changes.
I have tested wrapping Documents in
createMutable
but Foundry itself really doesn't work with that. Is there any reasonable way of still getting fine grained reactivity in this case?
Otherwise the options I can see right now are:
- just have a big Document signal that sends out an update whenever any property is mutated
- convert the Document into an object after every change, and reconcile the differenceFoundry Virtual Tabletop | Foundry Virtual Tabletop
The official website and community for Foundry Virtual Tabletop.
2 Replies
Sounds somewhat like Firebase. If you are interested:
- article
- repo
That said I think the fundamental issue is the attempt to adapt the generic document model into Solid.
I think you will have better luck if you focus on the "reactive needs" of the UI; i.e. in an ideal world what signals/stores would make this UI effective?
Once you know that, figure out what the document callbacks are that you need to subscribe to, in order to drive the reactive state inputs (
set[Signal]
, set[Store]
) (fyi: from
will provide a signal).
If at all possible drive mutations directly towards the document (as I'm assuming that the updates will be reported back via the callbacks anyway).
So whenever you have a list of things to show on the UI, you will most likely just force that list of items coming from the document through reconcile
to update the store that is projecting that list to the UI.SolidJS Todo App with Firebase - Code.Build 💻
SolidJS Todo App with Firebase - Code.Build 💻
I figured SolidJS would be just like React, but it’s not. It’s way better. I had a few learning curves but got my app up and
GitHub
GitHub - jdgamble555/solid-start-firebase
Contribute to jdgamble555/solid-start-firebase development by creating an account on GitHub.
Thanks for your input! That's also about the conclusion I ended up with. I actually just shove the whole huge document object into a signal, and do a setSignal with the same document, when I get informed about changes. Then down the line in the UI, I use smaller memos to cache values here and there, whenever profiling shows interesting spots. Even though that is far from optimal, Solid can still figure out pretty well where updates are needed.
Mutation is fully dealt with by Foundry itself. Just some methods on the documents themselves. The response though is just mutations to the documents.