re-frame

https://github.com/Day8/re-frame/blob/master/docs/README.md https://github.com/Day8/re-frame/blob/master/docs/External-Resources.md
metehan 2020-07-05T01:09:54.258500Z

metehan 2020-07-05T01:10:43.259100Z

Whats wrong with (_re-matches_ #"\S{1,}\/\S{1,}" "users/232")

2020-07-05T14:11:59.279Z

You don't need to escape /

👍 1
2020-07-05T14:12:11.279200Z

(re-matches #"\S{1,}/\S{1,}" "users/232")

2020-07-05T14:13:25.279400Z

The reason why you normally need to escape it is that you write it in the form s/.../.../ where everything is a string. You are not using this form in Clojure.

metehan 2020-07-05T01:11:50.259600Z

on <http://regexr.com|regexr.com> same regex is working

euccastro 2020-07-05T02:48:57.262Z

I'd like to subscribe to db changes on certain keys and trigger events if the resulting values meet some conditions. there are many different events that could change those db entries, and I don't want to have to add interceptors for all those, so I thought just subscribing for the output db state would be more elegant

euccastro 2020-07-05T02:49:47.262800Z

I'd like to do that outside of any reagent component, since this logic doesn't belong in any particular component

euccastro 2020-07-05T02:50:42.263900Z

do I need to explicitly watch for changes in the atom returned by re-frame.core/subscribe?

euccastro 2020-07-05T02:50:50.264300Z

or is there a more idiomatic way?

2020-07-05T03:06:47.272300Z

@euccastro Various options: First, you could add create an interceptor which detects the change and actions it (dispatches an event?) using a global interceptor ... written like the standard on-change one Second you can do it with subscriptions which isn't very idiomatic, but it isn't exactly hard either. I'll rustle up some code if you are keen .

euccastro 2020-07-05T03:09:18.273300Z

thanks @mikethompson!! I'll chew on those options for a bit..

euccastro 2020-07-05T03:10:37.274700Z

just wanted to make sure I wasn't missing some established way to do that kind of thing

2020-07-05T03:17:17.276400Z

Regarding the subscriptions approach ... It is a while since I've had to write this kind of code ... so I fear I might be be doing it wrongly, but here's the idea ...

(defonce some-name 
  (reagent/reaction  
    (do 
      @subscribe([:a-sub-to-watch-for-changes])
      (dispatch [:the-event])))

👍 2
2020-07-05T03:17:26.276600Z

@euccastro ^^

euccastro 2020-07-05T03:24:05.278200Z

thank you very much! I think a globally registered on-changes interceptor might work for my use case, since I actually want to effect derived db changes

2020-07-05T06:26:29.278700Z

Also this looks nice