Fork me on GitHub
#re-frame
<
2021-03-18
>
Schpaa15:03:33

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

Schpaa15:03:19

I used a (comment block) instead of #_ in a vector

Schpaa15:03:51

That was a first

az19:03:35

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?

p-himik19:03:58

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.

p-himik19:03:38

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.

az19:03:16

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?

p-himik19:03:14

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.

az19:03:13

Yes I agree, thank you for bringing this up.

superstructor13:03:13

@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.

az22:03:28

@U0G75S29H - Thank you, got it!