Fork me on GitHub
#clojurescript
<
2020-02-02
>
Gleb Posobin01:02:51

Hi! Does anyone have any recommendations on using indexedDB in cljs? I am trying to figure out what's the best way to store structured data for an offline cljs app, don't have any prior experience with thath.

p-himik08:02:54

If you can't find anything better, Transit will probably work. Maybe you can even prevent if from writing JSON strings and get JS objects directly.

borkdude16:02:12

How does one call the process of the Closure advanced compilation cutting away unused code? tree-shaking? it seems they don't use this word themselves: https://developers.google.com/closure/compiler/docs/api-tutorial3

borkdude16:02:50

I'll just call it dead code removal. (I'm asking because I'm making a presentation)

orestis16:02:27

Tree shaking in the JS world is usually done at the module level (find that a module is unused, remove the import entirely). AFAIK, DCE is much more aggressive and efficient, it can go down at the function level and also inline small functions and so on.

orestis16:02:16

The downside is that Google Closure needs to know about the entire program, which probably means it can’t apply anything to npm stuff.

orestis16:02:37

(Since they are usually taken out of the compilation process and treated as a binary blob)

p-himik16:02:08

The NPM code is still passed through GCC (at least, with shadow-cljs). But the optimizations level is set to simple, so no DCE.

Gleb Posobin21:02:24

This is probably a dumb question, but how do I await a promise in cljs? I can't seem to find anything about that, except for using a promesa library. I am using a js library (Dexie) that returns promises.

Roman Liutikov22:02:13

You can use promises directly via intereop syntax (.then p f)

Gleb Posobin23:02:41

Yes, that I am using now, wanted to know whether I can do await, seems like the answer is no. Will use callbacks, thank you!