This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-07-17
Channels
- # announcements (11)
- # beginners (29)
- # calva (2)
- # clara (12)
- # cljsjs (1)
- # cljsrn (7)
- # clojure (39)
- # clojure-europe (6)
- # clojure-nl (7)
- # clojure-spec (6)
- # clojure-sweden (1)
- # clojure-uk (15)
- # clojuredesign-podcast (6)
- # code-reviews (2)
- # conjure (29)
- # cursive (3)
- # datomic (13)
- # duct (15)
- # emacs (1)
- # figwheel-main (2)
- # fulcro (7)
- # graalvm (16)
- # lambdaisland (4)
- # luminus (1)
- # meander (15)
- # observability (15)
- # off-topic (27)
- # parinfer (7)
- # pathom (2)
- # reitit (2)
- # rum (11)
- # shadow-cljs (57)
- # spacemacs (6)
- # sql (56)
- # tools-deps (36)
- # xtdb (3)
I associate then
with the idea of asynchronis handling. So in the example below the first where i pass a fn to turn a response into json response makes sense.
fetch('')
.then(response => response.json())
.then(data => console.log(data));
However, the second call to then, to just to log seems odd. This shouldn't be async. Is this example just misleading in its usecase or is there something else going on here?i guess i is separated in time from the first thing. and given you need a catch it also flattens the logic out.
repeating a commonly known prefix is less noisy compared to nesting various kinds of forms to some? yeah it looks silly to me too
it's almost like an unrolled monad - simplifying the thing by putting every step in the same container
(simplified for human readers taht is)
Right i guess the main concern is avoiding nesting. i guess my first step function could do everything. But i ended up copying the pattern i saw and only later questioned it.
right, but the criteria for nesting here isn't a technical constraint, it's a human reader concern
predictable patterns are a great way to make bugs visible 99.5% of the time and impossible to see 0.5% of the time
especially because using redundancy for clarity increases the chances of accidentally correct reading of what the code does (that leads to a totally incorrect refactor)
@drewverlee it’s because fetch
resolves the promise as soon as headers come in, which means that the response might not be fully complete yet
so in this case response.json()
returns a promise that resolves once the body is fully available
i see. This makes sense with what i'm seeing. i tried to make it one step and it failed.
this is probably clear in the docs and im reading past it, thank you.
yeah, the API is clearer when you want to do something other than consume json. like stream a binary blob
i guess i picked it because it was "modern" and included. Maybe there is something more tailored for clojurescript http requests?
no matter what, you’re going to have to deal with async-ness of the request. raw AJAX requires using callbacks. fetch
gives you a promise interface, which for a lot of use cases is easier IMO
there’s cljs-http
which gives you a core.async
interface if you’re already use core.async
Not trying to promote Facebook or anything here -- just already have the pics and a Wikipedia link posted on my page here of a cool thing I noticed in my freezer today: https://www.facebook.com/andy.fingerhut/posts/3239965412693392
Guess I can just put a photo here directly. This ice tray had no special preparation -- just filled it with tap water from kitchen sink and put into my freezer. It hasn't done this before.
It's aliiiiiive! 🙂
Also, I don't think you made that post public -- so only your FB friends can see it anyway "This Content Isn't Available Right Now"
My wife found there is an article on “ice spikes” on Wikipedia that looks like this phenomena
There’s a SciShow video that explains it in relatively simple terms lemme see if I can find it.
https://www.youtube.com/watch?v=b9a36vsQh80 It’s the first thing they explain so it starts at around 45 seconds