Fork me on GitHub
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.


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.


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:


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


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.


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


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


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.


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!