Fork me on GitHub
#hoplon
<
2018-04-19
>
vschepik08:04:52

@alandipert Yes, it is confusing how the compilation model in cljs and the REPL can co-exist. But I will go for your advice. I also learned to love the debux lib that is simple and powerful for pretty printing stuff in the console.

thedavidmeister10:04:33

i just wrote this time syncing algo for javelin - https://github.com/thedavidmeister/javelin-timesync - for anyone who wants to sync UIs across devices

vschepik13:04:26

Is there any way to save the state of a Javelin cell when boot-reload reloads the JS code? The reason is that I am storing responses of REST calls in a cell and do not want to call the REST endpoint everytime I hit Save in my editor.

thedavidmeister13:04:57

you can stick it in session storage or local storage

thedavidmeister13:04:47

is that what you're asking?

vschepik13:04:15

Yes, that looks good!

vschepik13:04:46

I will try that

thedavidmeister13:04:47

(defonce state (hoplon.storage-atom/local-storage (j/cell nil) ::state))
(defonce nonce (hoplon.storage-atom/local-storage (j/cell nil) ::nonce))
(defonce token (hoplon.storage-atom/local-storage (j/cell nil) ::token))

thedavidmeister13:04:49

this kind of thing

thedavidmeister13:04:18

also you can memoize functions that return cells and get the same cell every time

thedavidmeister13:04:25

you might find that handy

vschepik14:04:33

OK. It's not clear to me what boot-reload reloads. But I will try what you have suggested.

vschepik14:04:28

That was exactly what I was looking for 😃 Thanks!

alandipert14:04:38

another thing i will do is comment out the code that fetches the value, and hardcode it

vschepik14:04:51

I did this in a different non-Hoplon project, too. But for that I had Emacs connected to a cljs repl in order to fetch the value directly into the editor. With Hoplon I had problems to get the cljs repl running but now it works.

alandipert14:04:00

defonce is probably also better because using local storage or hardcoding require the saved object to be print-readable

vschepik14:04:53

Yes, defonce is great.

vschepik14:04:15

By the way what is the namespace of a page?

alandipert14:04:53

it's not a macro or a function, it's compiled to ns by the hoplon boot task. in hoplon.boot-hoplon.compiler

alandipert14:04:29

well, an ns and conversion to .html

vschepik14:04:50

OK, so what would the ns of (page "index.html") be?

alandipert14:04:46

i think something like hoplon.app-pages.-index.html

vschepik14:04:09

I am asking because I want to switch to that namespace in the repl.

alandipert14:04:10

you can see what it generates with boot hoplon show -f to see the fileset after hoplon task runs

alandipert14:04:38

it might be better with a repl involved to not use page or .hl extension, and keep things vanilla cljs

vschepik14:04:09

OK. Perhaps I don't need the repl since local-storage will help me

vschepik15:04:11

Now I see the ns expression. Thanks. I will check out what a good workflow could be for me. Thanks!

👍 4