Fork me on GitHub
#re-frame
<
2020-07-05
>
metehan01:07:43

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

Pavel Klavík14:07:59

You don't need to escape /

👍 3
Pavel Klavík14:07:11

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

Pavel Klavík14:07:25

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.

metehan01:07:50

on same regex is working

euccastro02:07:57

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

euccastro02:07:47

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

euccastro02:07:42

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

euccastro02:07:50

or is there a more idiomatic way?

mikethompson03:07:47

@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 .

euccastro03:07:18

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

euccastro03:07:37

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

mikethompson03:07:17

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

👍 6
euccastro03:07:05

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

David Pham06:07:29

Also this looks nice