Fork me on GitHub
#clojurescript
<
2018-05-11
>
philrees02:05:24

Hi everyone! I'm looking at using these react components with an Om app. https://github.com/stripe/react-stripe-elements/blob/master/README.md Is this possible?

philrees02:05:46

I have read this http://brentvatne.ca/js-react-components-in-om/ and this post makes good sense to me. It is the HOC aspect of the stripe ones that I am getting hung up on

Oliver George02:05:28

Hi. Is there a low fuss way of doing await in clojurescript without depending on core.async? Context is I want to treat an async api which uses promises as blocking.

justinlee03:05:37

@olivergeorge the promesa library has some macros that emulate await. i have found that it isn’t perfectly general but it does work

justinlee03:05:05

you can also just use then and catch as they are normal methods. the promesa library helps with the ergonomics of that too

Oliver George03:05:49

Thanks. I'll check promesa out.

Oliver George03:05:00

(scratch that)

justinlee03:05:22

oh be sure to check out the alet macro they have. i have found that when i really need await-like semantics, that’s good enough and it is more “clojureish”

justinlee03:05:47

but again, you can just use promises using js interop

Oliver George03:05:09

Yeah, it's the blocking bit which complicates. Perhaps I'm asking for something silly.

justinlee03:05:41

i mean, keep in mind, await does not really block. it just makes code that looks like it blocks. any function in javascript that uses await returns a promise

Oliver George03:05:52

Okay, perhaps it's not really what I'm after.

justinlee03:05:16

you literally cannot block. it’s the hard lesson of javascript 🙂

justinlee03:05:18

(well in node you can, but not in the browser)

Oliver George03:05:15

(FYI I'm thinking about re-frame event handlers. There's no place for async data preparation before they run which makes async data sources inconvenient and incompatible as coeffects.)

justinlee03:05:03

try in #re-frame because they’ve definitely thought about how to do this in some proper way. i don’t use it myself because words like coeffects are scary 😛

Oliver George03:05:55

🙂 will do. For what it's worth you learn to love them.

justinlee03:05:34

by the way, my random guess is that the answer will be: do it async and fire off another event when the result comes back

Oliver George03:05:16

Yeah, I think you are right. I could wrap that up so it's a little less verbose too.

danielneal08:05:22

yeah, I use async storage as an effect, not a coeffect, and fire off an event when the result comes back

ajk13:05:30

Question about resolving protocols in ClojureScript,

(defprotocol Testy
  (testy-this [_]))
In Clojure I can get a list of the signatures:
(:sigs Testy)
{:testy-this {:name testy-this, :arglists ([_]), :doc nil}}

;; or in a macro
(:sigs @(resolve Testy))
In ClojureScript both of these give me nil, is there another way to get a list of the signatures of a Protocol in CLJS?

mfikes14:05:09

@alexanderjamesking I don't think this is guaranteed to always work, but

(-> #'Testy meta :protocol-info :methods)

ajk14:05:28

Thanks @mfikes - that looks to have done the trick

elbow-jason23:05:20

hey all I have I'm going through the om basic tutorial at https://github.com/omcljs/om/wiki/Basic-Tutorial . My om/root looks like:

(om/root
  (fn [data owner]
    (om/component
      (apply dom/ul #js {:className "animals"}
        (map stripe (:list data) (cycle ["#ff0" "#fff"])))))
  app-state
  {:target (. js/document (getElementById "app0"))})
and when my app-state (`data` in the om/root scope) is:
(defonce app-state (atom {:text "Hello world!"}))
I get no warnings or errors even though the code should be mapping over the data. Is this normal?

elbow-jason23:05:52

more specifically: Why is this not an error?