This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-01-02
Channels
- # beginners (29)
- # boot (65)
- # cider (12)
- # cljs-dev (8)
- # cljsjs (31)
- # clojars (5)
- # clojure (147)
- # clojure-austin (47)
- # clojure-berlin (1)
- # clojure-brasil (7)
- # clojure-russia (5)
- # clojure-spec (18)
- # clojure-uk (18)
- # clojurescript (113)
- # css (2)
- # cursive (7)
- # datascript (5)
- # datomic (2)
- # dirac (4)
- # events (3)
- # funcool (143)
- # hoplon (287)
- # jobs (2)
- # off-topic (4)
- # om (10)
- # om-next (5)
- # onyx (18)
- # protorepl (1)
- # re-frame (93)
- # reagent (34)
- # rum (41)
- # test-check (51)
- # untangled (15)
- # yada (18)
And to @qqq, general advice I would give is that If you can find a tutorials for it that you can understand/know how to do it on one and you dont plan to have a backend that is complex enough to give too much thought to the finer points of your server, puts names in a hat.
@thheller Really? I mean resource aggregation makes sense with http/1. Much less with http/2.
and adding a Link: <https://example.com/other/styles.js>; rel=preload; as=script
http header or html <link>
As a newbie starting to learn cljs (focus on react / react-native) .. Should I focus on boot or lein more
Hi All, wondering what people would suggest in an odd situation I’m encountering working with a js library that works on promises (or mostly on promises). Consider this code:
(let [rv (transient [])]
(-> (open-repo)
(.then #(.getMasterCommit %))
(.then #(.getTree %))
(.then (fn [tree]
(-> (.walk tree)
(.on "entry" #(conj! rv (build-entry-data %)))
(.on "end" #(js/console.log (clj->js (persistent! rv))))
(.start))))))
This is code that uses nodegit to interact with a git repo. What it basically does is try to gather an array of file objects for all that files in the repo. The problem I’m encountering is that the piece that traverses this git object tree (the walker produced by (.walk tree)
is an EventEmitter rather than a promise. So whereas the above code should return an array of promises for each file object, instead it can only return the walker. The function returns, in other words, before the “end” event fires. If I were writing JS, I’d probably fashion the block enclosing the tree walker as a Promise, return that, and manually resolve
when the end
event fires. But I’m unsure how to handle this in clojurescript… Can anyone suggest a good approach?@kim0 it doesn’t really matter, the only time it would make a difference is if you want to use Cursive/IntelliJ (doesn’t understand boot yet)
Terminology question: How do people call something that behaves like an atom but may not be? (reagent/atom, reagent/cursor)
my ideas: dereffable, atomic
@pesterhazy IDeref
is for deref’ing, the watch capability is IAtom
right
[input-ui ideref]
doesn't quite roll off the tongue though
(as in a reagent component)
re-frame uses model
hm state sounds good
@dnolen I think my question is how one would go about doing that. Creating the promise also through interop? (like (def promise (fn [resolve reject] …))
) Or is there a more vernacular way of creating a promise?
@ezmiller promises is JS concept, not a ClojureScript one - there is no idiomatic way of dealing with this - it’s just interop
@dnolen okay duly noted. I think my confusion comes from having noticed (but so far avoided thinking about) things like promise
and promise-chan
in the clojure docs...
is om tightly coupled with react
? anyway to use libraries like preact
with preact-compat
in om ?
@renlinx it is coupled to react, making it work with other things is interesting but not a priority for me - btw there’s an #om channel
@ezmiller yeah those are core.async things - and the semantics are a bit different from JS promises
@dnolen I’ve been surprised that I haven’t needed to get into those clojure async concepts yet. By contrast, I’ve also been wondering whether the fact that I often end up working with JS promises in cljs code means I’m doing something wrong. That is the broader context for the question I think.
@ezmiller if you’re using a library which relies on promises I don’t see how you can avoid it
@ezmiller: fwiw, I use the funcool/promesa library and I often wrap interop promises inside them when necessary
https://github.com/mayopta/library-asset-tag/blob/master/src/cljs/library_asset_tag/ui/auth.cljs
Yeah. I originally started using promesa for de-callbackifying interop code in general, but I found it works well for even interop with things that already supported promises
I'm sure there are other ways to do it and probably more elegant ways, but thought I'd share
a good way to do this would be to have a thin wrapper that returns a core.async/promise-chan no?
I'm using Form-2
(defn component [props]
(let [something "something"]
(fn []
[:div "test"])))
@jsus Form 2 components pass their parameters from the outer scope to the inner function, so in your case "component" takes one arg "props", so the inner (fn [] ..) should be of the form (fn [props] ...) Try that and see if it solves your issue.
If you wouldn't mind, perhaps a screenshot or the full code snippet might help me spot the issue
Also the output from your browser's console might be helpful if an error is appearing there
Also remember that while reagent components are functions, you don't actually want to call them like functions
So like if you have (defn root [] (component)) That will only work for type 1 components. For type 2 and 3 (and also for type 1 so that reagent can cache results), put the components in vectors like (defn root [] [component])
@kim0 I think it is passed to lein new
@richiardiandrea Thanks .. so I guess this means that lein can add reagent to almost any template ?
@kim0 no basically probably the figwheel
template handles it
https://github.com/bhauman/figwheel-template/blob/master/src/leiningen/new/figwheel.clj#L38
@jsus the code you provide seems fine (although rightly corrected by @emccue for inner props), so there's something else going on. Perhaps take this across to the #reagent channel.
hello guys, I am reading the om
code; does anyone know what
(extend-type default,,,)
doesI mean default
because I know what extend-type
does 🙂
@baptiste-from-paris it defines a default implementation in case some type is encountered which doesn’t implement it directly
@dnolen thx 🙂! and where the default
value comes from ?
@baptiste-from-paris I don’t know what you mean
let me try to translate noob -> english
ok I found the answer
* default, meaning the definitions will apply for any value,
unless an extend-type exists for one of the more specific
cases below.
in the doc
@dnolen do you know if there is an annoted explanation of om
?
@baptiste-from-paris there is not, also there is an #om channel
ah ok, sorry 🙂
@dnolen We spoke a while ago about user-defined analysis passes in the CLJS compiler. Is that currently a thing, or is it a future plan?