Skip to content
This repository has been archived by the owner on Sep 26, 2023. It is now read-only.

Basic global state subscriptions + updates #42

Open
den1k opened this issue Feb 13, 2020 · 5 comments
Open

Basic global state subscriptions + updates #42

den1k opened this issue Feb 13, 2020 · 5 comments

Comments

@den1k
Copy link
Contributor

den1k commented Feb 13, 2020

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.

@roman01la
Copy link
Owner

roman01la commented Feb 14, 2020

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))

@den1k
Copy link
Contributor Author

den1k commented Feb 14, 2020

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

@den1k
Copy link
Contributor Author

den1k commented Feb 17, 2020

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.

@roman01la
Copy link
Owner

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

@den1k
Copy link
Contributor Author

den1k commented Mar 10, 2020

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.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants