Fork me on GitHub
#cljsrn
<
2018-05-08
>
mfikes00:05:44

Here is an initial cut https://github.com/cljsrn/side-fx I'll work to clean it up (for example, the fetch API is a little heavy handed with clj->js and it also shouldn't unconditionally assume JSON is being returned.

Oliver George00:05:15

Cool. I'll check it out.

Oliver George00:05:36

Yeah, I'd lean towards conservatism with regards to js->clj and back. Particularly associated with request params and json body on posts.

Oliver George00:05:54

Only other immediate feedback is that re-frame explodes noisely when there's no matching event handler. That's why I use (when on-success (dispatch on-success)) rather than a [::no-op] default.

Oliver George00:05:08

Also, your fetch-fx bakes in json decoding. Certainly fits the common case. Perhaps needs a json specific sounding name to match.

Oliver George00:05:40

All that aside seems useful without being opinionated. +1

mfikes00:05:47

Cool. I've copied the http-fx pattern of using :or to ensure something for on-success. I'll look into how that is insufficient.

mfikes00:05:18

And, yeah, it shouldn't unconditionally assume JSON

dotemacs08:05:19

So much cool info/activity on this channel in the last few days. Thanks @olivergeorge & @mfikes 🙂

👍 4
💯 4
Oliver George09:05:54

@mfikes It turns out (.getItem AsyncStorage "invalid") will nil result and no error. I think storage-fx might need to wrap values so it can detect misses.

Oliver George09:05:25

e.g. (.setItem AsyncStorage (pr-str key) (pr-str {:data data})...)

Oliver George10:05:10

Possibly just testing for a string result would suffice actually.

Oliver George10:05:48

Slightly less neat but this is what I had in mind

(defn get-item
  [{:keys [key on-success on-failure]}]
  (.getItem AsyncStorage (pr-str key)
            (fn [error result]
              (cond error
                    (dispatch on-failure {:type :fault :error error})
 
                    (nil? result)
                    (dispatch on-failure {:type :unavailable})
 
                    (string? result)
                    (try (dispatch on-success (read-string result))
                         (catch :default e
                           (dispatch on-failure {:type :fault :error e})))))))

Oliver George10:05:26

With a helper to clean up the code a bit

(defn dispatch [ev & args]
  (when ev (re-frame/dispatch (into ev args))))

Oliver George10:05:04

Note: For kicks I've thrown in error types based on https://github.com/cognitect-labs/anomalies

Oliver George10:05:39

Answering my own question. cljs-devtools works just fine with Remote JS Debugging.

Oliver George11:05:30

One caveat is that the :preloads compiler option doesn't work so you need to add it to your main ns

mfikes11:05:07

Cool @olivergeorge I put in your suggestion, namespacing the keys to make it easier to spec later. I left the dispatch stuff alone for now. We can change it later if desired... it is currently following https://github.com/Day8/re-frame-http-fx/blob/master/src/day8/re_frame/http_fx.cljs#L42-L43 which seems to at least let you know you failed to set a handler (or alternatively you can set a default one for that case)

👍 4
mfikes12:05:57

I've started capturing issues in that repo

mfikes15:05:56

If anyone has some knowledge surrounding re-natal's Figwheel bridge operation, this is a good one to chew on and perhaps solve: https://github.com/drapanjanas/re-natal/issues/179

alvina16:05:11

I am getting following error with expo react native -

alvina16:05:13

Exception in thread "main" java.lang.ExceptionInInitializerError at clojure.main.<clinit>(main.java:20) Caused by: clojure.lang.ExceptionInfo: Error duplicate key spec {:k :figwheel-sidecar.schemas.cljs-options/process-shim}, compiling:(figwheel_sidecar/schemas/cljs_options.clj:592:1)

alvina16:05:50

i have install the npms with 'yarn install'

alvina16:05:02

singing up exp

alvina16:05:27

lein figwheel blows up

alvina16:05:07

with this error

hoopes23:05:37

hi, i'm following the instructions here https://github.com/flexsurfer/re-frisk/wiki/Using-re-frisk-with-re-natal to try to get a re-frisk debugger going with re-natal, and the server starts, but the contents of the 3 panels are just a green "not connected" - is there a step missing, or is there some other action i need to take to get it all linked up? (If there's a better channel to ask, please let me know) Thanks!

dima07:05:18

If you’re using android simulator, you probably need to open port 4567 adb reverse tcp:4567 tcp:4567. Also, have you checked network and js errors in devtools console on http://localhost:4567 ?

hoopes12:05:26

yeah - it looks like there's a ping error every once in a while in the network panel, which is probably the actual problem, but the page is loading fine, and the websocket looks connected fine. All ports are open correctly, afaict.