Currently we fix the Datascript conn to a defonce var at initialization. This allows us to keep the state even after a figwheel reload.
However, this also created a proliferation of stateful components. Pretty much every component has a (work/pull! ...) or (work/q! ...) which by themselves are not wrong, but when combined with global state it can create a mess; specially for testing since you would need to re-create the global context to test the component.
One option would simply be to pass the Datascript conn as a Reagent ratom around. Although the components would still be stateful, they would then become much more easy to test as the state is local and can be re-created very easily.
Currently we fix the Datascript conn to a
defonce
var at initialization. This allows us to keep the state even after a figwheel reload.However, this also created a proliferation of stateful components. Pretty much every component has a
(work/pull! ...)
or(work/q! ...)
which by themselves are not wrong, but when combined with global state it can create a mess; specially for testing since you would need to re-create the global context to test the component.One option would simply be to pass the Datascript conn as a Reagent ratom around. Although the components would still be stateful, they would then become much more easy to test as the state is local and can be re-created very easily.