uix icon indicating copy to clipboard operation
uix copied to clipboard

Basic global state subscriptions + updates

Open den1k opened this issue 5 years ago • 5 comments

Is your feature request related to a problem? Please describe. I'm currently using the re-frame-like xframe for global subscriptions and state updates. However, in many of my use-cases I merely need get-like and get-in-like subscriptions and assoc/update(-in)-like handlers.

Describe the solution you'd like Reagent's ratom + cursor compatible with reacts hooks. Like this but global.

Describe alternatives you've considered xframe has been my alternative so far. I think it would be nice to provide a less opinionated solution to global state updates and subscriptions.

den1k avatar Feb 13 '20 17:02 den1k

Would something like this work for you?

(def db (atom {:items [{:id 1}]}))

(def item-1 (cursor-in db [:items 0]))

(defn change-item! []
  (swap! item-1 :id inc))

roman01la avatar Feb 14 '20 13:02 roman01la

If derefs of item-1 in UI components result in reactive updates upon change, then yes, exactly

den1k avatar Feb 14 '20 16:02 den1k

Side note: another problem this would alleviate is not being able to render multiple apps in the same browser context because the current xframe impl uses only one db adapton.

den1k avatar Feb 17 '20 15:02 den1k

This is a separate issue, feel free to file a ticket for that.

roman01la avatar Feb 17 '20 15:02 roman01la

Hi @roman01la! Anything I can do to help with this feature? I've looked over the xframe source but it goes above my head. But I could probably put a PR together w/ some pointers from you.

den1k avatar Mar 10 '20 17:03 den1k