Fork me on GitHub
#shadow-cljs
<
2018-12-02
>
thheller09:12:01

@vigilancetech thats odd. do you know which part of you code triggers this?

thheller09:12:13

(this is definitely not related to the warning change)

Logan Powell16:12:53

I'm trying to keep some functions' internal state available between function calls... While using local let bindings seems to do the trick while working in the REPL, once I shadow-cljs release to an :npm-library and import the work, the functions seem to be losing their internal state across calls. I'm not sure how to fix this (or if it's even possible), but I see that :rename-prefix-namespace creates a global var in JS. Might this keep those internal function bindings "alive" between calls?

Logan Powell16:12:18

This is just a snippet/abbreviated version... the spooler actually merges a number of different external resource APIs' results together

thheller16:12:33

saw that snippet in #clojurescript but could not make sense of it

Logan Powell16:12:44

haha, sorry, I suck at snippets

thheller16:12:49

(ns app.core
	(:require [app.spooler :refer [spooler]
			   cljs.core.async :as a]))

Logan Powell16:12:51

The point of the matter is that the local (let [cache... bindings are working in cljs, but not when I release the cache is never reached by the function across calls

thheller16:12:52

this is invalid

thheller16:12:57

I assume that only because its a snippet?

Logan Powell16:12:14

I tried to make a small snippet

Logan Powell16:12:54

that basically represents the complexity of the problem

thheller16:12:10

to me the go looks invalid

thheller16:12:34

again might just be due to snippet but creating a fn inside a go block is a no no

thheller16:12:42

and calling >! in there even more so

Logan Powell16:12:10

I forgot, it's just a representation... the actual code works 100% of the time in cljs

thheller16:12:50

then nothing is ever put in =I= AFAICT?

Logan Powell16:12:50

I think it has something to do with the fact that when I release the function is wrapped in a self-executing context, which is run and then thrown away

thheller16:12:12

the code semantics don't change in :advanced

thheller16:12:37

and the code above doesn't produce any extra globals?

Logan Powell16:12:25

this is the actual function that I try to create a local cache

thheller16:12:38

no idea. don't see anything that would behave any differently in :advanced

Logan Powell16:12:54

ok, I'll keep hacking 😉

thheller16:12:11

you might get that done way easier with a transducer

Logan Powell16:12:25

basically, I'm trying not to have to call all the remote resources on every call when any of them are the same as last call and merge them together from cache if valid

Logan Powell16:12:45

the code is not easy to understand. I don't even know how to create a good snippet, but the most important thing is that those returned volatiles are never getting the chance to get used when I import the compiled js

thheller16:12:27

(prn [:call url @$url$ ...]) just to verify that everything is what you think it is?

Logan Powell16:12:06

I have done essentially that... the url's get printed every time

Logan Powell16:12:46

when I run the code from the REPL, I get something like:

getting data from source:
...

(run the function again with the same args)

getting data from cache:
...
but when I use it in js land I get
getting data from source:
...

(run the function again with the same args)

getting data from source:
...

thheller16:12:28

I'd still output everything together .. just to verify that actually IS what you think it is

thheller16:12:37

not that your cond is what you think it is

Logan Powell16:12:57

but why would it work in the REPL and not in JS?

thheller16:12:15

the REPL is JS so no idea what that means

Logan Powell16:12:32

that's my point though... I don't know why it would be different

Logan Powell16:12:59

Let me give your advice a go

thheller16:12:11

maybe you are just calling it differently in the actual app vs REPL

thheller16:12:34

like calling the $GET$ again instead of re-using

thheller16:12:40

no idea. gotta go 🙂

Logan Powell16:12:52

thank you as always for your help

Logan Powell16:12:12

btw, still waiting on that Patreon page 😉

Logan Powell18:12:35

Got it working!

👍 8
vigilancetech21:12:30

@thheller no, and right not it escapes me how to find it out. I'll have to start with a minimal working "hello world" project and start adding stuff till it breaks I guess.

thheller21:12:51

you could try git bisecting but thats kinda tricky to set up currently

vigilancetech21:12:16

oh, yeah, okay, well, something to check out. Thanks.

thheller23:12:33

its also fine to just downgrade to 2.6.24 for the time being