This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-03-18
Channels
- # announcements (31)
- # asami (11)
- # aws (33)
- # babashka (30)
- # beginners (69)
- # calva (1)
- # chlorine-clover (10)
- # cider (3)
- # clj-kondo (24)
- # cljdoc (19)
- # cljs-dev (1)
- # cljsrn (2)
- # clojure (104)
- # clojure-australia (4)
- # clojure-dev (29)
- # clojure-europe (202)
- # clojure-germany (36)
- # clojure-nl (6)
- # clojure-poland (3)
- # clojure-serbia (6)
- # clojure-spec (18)
- # clojure-uk (32)
- # clojurescript (36)
- # conjure (1)
- # core-async (6)
- # datomic (15)
- # duct (1)
- # emacs (11)
- # fulcro (24)
- # graalvm (12)
- # jobs (3)
- # juxt (1)
- # kaocha (2)
- # keechma (4)
- # lsp (1)
- # malli (102)
- # meander (17)
- # off-topic (16)
- # pathom (8)
- # re-frame (12)
- # remote-jobs (7)
- # rewrite-clj (72)
- # shadow-cljs (27)
- # sql (26)
- # tools-deps (8)
- # vim (3)
- # xtdb (28)
- # yada (5)
What would trigger something like this:
router.cljc:204 Uncaught #error {:message "Unexpected compile spec type", :data {:given nil, :type nil}}
eval @ router.cljc:204
eval @ router.cljc:151
eval @ router.cljc:169
eval @ router.cljc:183
eval @ router.cljc:198
eval @ router.cljc:146
eval @ router.cljc:169
G__54585 @ router.cljc:187
channel.port1.onmessage @ nexttick.js:218
Hi all, am I correct in understanding that interceptors are meant to be synchronous? I see examples of pulling from localStorage, but I’m wanting to use the localforage
lib which is async. Should I instead be using an effect handler for any async work?
Yes, interceptors do their job right when the event is processed. You could make a particular interceptor async, but it's probably not worth it - it would heavily rely on re-frame internals.
You could use an effect to set values, but you can't get them back.
But why would you want to use localforage
in the fist place? The underlying localStorate
is not async, meaning that using localforage
won't give you any performance benefits and it's exactly like using localStorage
+ promises + some particular serialization library (since localforage
handles more than just strings).
You can do all that (without the promises part since you don't need async) with just localStorage
and have one dependency less and cleaner code without all the .then
.
Ah, there's this section that I missed: > includes a localStorage-backed fallback store for browsers with no IndexedDB or WebSQL support So it's not really a local storage thing. Yep, it has been asked before. It's unfeasible to use IndexedDB with re-frame exactly because it's async, and same follows for localforage.
Thank you @U2FRKM4TW for the breakdown. So in general if I must use something async, I should only look at effect handlers? Maybe use something like async-flow-fx
or just write handlers and string them together?
If it's something effectful, yes. getValue
, for example, is not effectful by itself. You could put it into the app-db
right in that effect handler though.
But in the case of localStorage, I would still rather use it directly, without any wrappers that just make you write more boilerplate.
@U2FRKM4TW is correct. Just to be clear if it is async state, like get a value from a server or get gps co-ordinates or just an async db, then it needs to be an effect with an on-success/on-failure etc event vectors to dispatch with the result.
@U0G75S29H - Thank you, got it!