day8 / re-frame-10x

A debugging dashboard for re-frame. X-ray vision as tooling.
MIT License
634 stars 68 forks source link

add 'refresh' functionality to app-db #206

Closed sloxy closed 5 years ago

sloxy commented 6 years ago

I'm proposing to refresh app-db re-frisk view (either when tab gets focus - so clicking off and then back to the app-db view would refresh it) or add a button to force read.

Sometimes, when developing/debugging, I may set a value in the app-db directly via the repl

(assoc @re-frame.db/app-db :name "value-2")

When I do this, the web page will update the new value, but the app-db screen in re-frame-10x tools does not update (in this case; when I navigate to diff page)

issue recreated on new project created using lein new re-frame first-proj +10x +re-frisk +test +handler +routes
& then
lein figwheel dev

screenshot of inconsistency:

re-frame-10x-feature-request_li

danielcompton commented 6 years ago

@sloxy the way we capture app-db information is by instrumenting the before and after of app-db when a handler is run. If you manually modify app-db outside of the re-frame event cycle then we won't be able to capture the information.

An alternative approach to this would be for you to manually dispatch events from the REPL to move your app-db into the desired state. These would be captured and would update app-db. Another option would be for you to make a no-op 'refresh' event that you dispatch/click after updating app-db, that should then get access to your manually updated app-db state.

I'll consider this feature request, but due to the way re-frame-10x is architected to instrument a running re-frame system, it wouldn't be trivial to implement. If this turns out to be a really common use case then we may consider adding it, but I'd lean towards not at this point (readers: add a 👍 on the original post if this would be useful for you).

danielcompton commented 5 years ago

I'm still not really sold on this idea and implementing it would also be really hairy/impossible to do with the current tracing architecture.

Instead, for now I'd recommend you create an identity event that you can call when you want to 'refresh' app-db. This event handler would take and return app-db unmodified which would then trigger the rest of 10x to update the GUI.

Going to close this for now. If someone is really keen on this then I maybe would consider a PR, but please get in touch first with your plans before you write too much code.