Fork me on GitHub
#clojurescript
<
2018-07-31
>
richiardiandrea00:07:42

so say I am in a macro and I use backtick

richiardiandrea00:07:01

it seems like it cannot resolve js-obj

richiardiandrea00:07:42

I have to use the fully qualified cljs.core/js-obj, is this expected or an issue I can raise?

abdullahibra09:07:41

https://github.com/aibrahim/user_management this is a demo for login/signup users demo, i have problem with after login when refresh the page i lost the session and get login page again

abdullahibra09:07:59

before using it you need to create database, username owned the db with password,

abdullahibra09:07:49

i can't figure this out, please if someone can help in it, i appreciate

valtteri10:07:23

@abdullahibra when browser refresh happens, it loads all javascript files again, which means that you end up in initial state

(def app-state (reagent/atom {}))
(def pages (reagent/atom {:current nil}))

valtteri10:07:44

Is this the problem you’re having?

abdullahibra10:07:10

will the session lost also?

valtteri10:07:29

Where is your session?

valtteri10:07:33

On the server? In cookies?

valtteri10:07:38

Client side only?

abdullahibra10:07:29

my session on the server, so i need to handle client to keep logged in even after reloading the page

valtteri10:07:15

Ok, se your server knows that the client is logged in, so after refresh you have to call the server and ask it “is this user logged in” and then render the ui accordingly

abdullahibra10:07:59

via rest API ?

valtteri10:07:29

Well, there are several ways how you can achieve what you’re trying to do.

abdullahibra10:07:07

what is the most secure way to do it?

valtteri10:07:32

I suggest that you look up a a few templates that does that for you and study the implementation.

abdullahibra10:07:56

which templates?

valtteri10:07:06

Security and usability are usually tradeoffs. 🙂

valtteri10:07:24

For example luminus is a framework that has variety of options how to deal with authentication. You can generate a working skeleton project using leiningen templates https://github.com/luminus-framework/luminus-template

abdullahibra10:07:14

actually my project is created using luminus +auth

valtteri10:07:49

Ah, ok cool. Then probably guys at #luminus know best how to help you. 🙂

valtteri10:07:19

By quick check it seems like luminus sessions uses in-memory solution to store the sessions on server side. Anyways, if you just refresh the browser it shouldn’t affect the server. Unless your frontend code does some ajax calls to the server on initialization that can invalidate the session.

valtteri10:07:15

So my guess is that it’s a frontend issue and you probably need to add some kind of way to check if the user is logged in or not, that survives the browser refresh. Most common options for this are a) request from backend b) cookies c) browser local-storage

punit-naik10:07:35

Hi Guys! Does anyone here have an example cljs code of any UI/Web App written using metosin/vega-tools or yieldbot/vizard? Thanks.

borkdude12:07:32

;; JVM
(namespace (keyword "")) ;; http:
;; CLJS
(namespace (keyword "")) nil

lilactown15:07:20

have a simple question about reload-a-bility

lilactown15:07:46

I currently have my entry point setup like so:

(defn ^{:export true
        :dev/after-load true}
  start! []
  (load!)
  (t/info "Started"))

(start!)

lilactown15:07:08

I need to set :dev/after-load true so that it will re-start my application when I modify another ns, but I also need to put the start! at the end in order for it to start my application when the page loads

lilactown15:07:30

however what this means is that when I modify the entrypoint, my start! fn triggers twice

lilactown15:07:01

is there a way to have that start! at the bottom only trigger on script load?

lilactown16:07:23

@thheller I did that at first, but then I wanted to have my entrypoint <script> async

lilactown16:07:11

I spent a couple hours trying to detect when the script loaded, then call init! but eventually gave up and went back to just calling start! at the bottom

thheller20:07:36

ah totally forgot. in shadow-cljs you can set :modules {:foo {:init-fn some.ns/start!}} as well (instead of :entries or in addition to). that will only be called once.

lilactown19:07:19

has anyone setup so that CLJS automatically instruments specs when in development?

lilactown19:07:59

I'm thinking of checking goog.DEBUG, but am worried that the clojure.spec.test.alpha NS will still get bundled

kennytilton19:07:21

Is there any way to turn of cljs devtools at runtime? I looked at all the configuration doc and it is copious but seems to assume I am a heavy-duty cljs-devtools user.

thiru19:07:07

Hey everyone, I'm pretty new to ClojureScript

thiru19:07:43

Just curious what setup you have with your REPLs and editors. Do you keep your Clojure and Clojurescript REPLs separate?

mauricio.szabo21:07:08

I'm using Atom, and I wrote a plug-in to work with multiple REPLs. It's not perfect yet, but it works most of the time

mauricio.szabo21:07:13

What I use is Figwheel with Sidecar, then I start figwheel inside nREPL and use Atom to connect to it (with clojure-plus and proto-repl). Works most of the time, it's just kinda slow to evaluate CLJS code

thiru19:07:54

Sorry, I should ask this kind of thing in the #beginners channel

kwladyka20:07:44

@thiru0130 you run cljs REPL in clj REPL. Tell people what editor you use, this will help to help you 🙂 Also it looks different depend on you use lein vs shadow-cljs or figwheel vs something else.

kwladyka20:07:07

personally I recommend shadow-cljs, but make your own opinion

kwladyka20:07:40

well… and I am not sure it is right way for beginner to start with

bbss20:07:58

if you come from the npm ecosystem it might be

kwladyka20:07:02

I don’t remember my beginning 🙂

kwladyka20:07:49

editors: cursive intellij vs emacs. I can recommend this 2. Others are not enough mature IMO.

eggsyntax21:07:00

Would someone remind me if there's a cljs equivalent to clojure.main/repl, ie a way to start a cljs repl from within cljs? Finding it hard to google for, and not immediately finding it in the cljs source code.

eggsyntax21:07:29

I'm not sure there would be, since IIRC the cljs repl is run from clj...

eggsyntax22:07:33

Huh. I see a repl fn in src/main/clojure/cljs/repl.cljc, not wrapped in a reader conditional, which would make me think I could call it, but I seem to be unable to.

bhauman22:07:14

@eggsyntax I'm assuming you are in self host environment?

bhauman22:07:46

then you can't start of REPL from CLJS

eggsyntax22:07:51

Ordinary lein project.

eggsyntax22:07:56

Ah, ok, that's what I feared.

john22:07:05

Added a simple animation to the tau.alpha demo to give a better idea of the screen lag: https://johnmn3.github.io/tau.alpha/ Also, question: Where would folks prefer a tau's (atom-like thing, shared between web-workers) watcher fns fire off? On the worker that last updated the tau? Or the worker that created the tau? Or the worker that added the watch-fn to the tau? Or should there be a subscription mechanism from any worker to specific watch keys? The semantics differ slightly from CLJ because most state in each worker is not shared between them, and only the screen thread has access to certain functions like those in js/document.

bhauman22:07:07

and even in a self host environment it's doubtful

eggsyntax22:07:40

Interesting that the fn throws as undefined, since it's in a cljc file. Issue with the source path not being present, maybe?

bhauman22:07:31

you would have to require that file as a cljs require

eggsyntax22:07:50

Well, I was requiring it in a cljs repl.

bhauman22:07:58

but more importantly why are you trying to start a cljs repl from cljs?

eggsyntax22:07:10

Because WHY NOT 😆

eggsyntax22:07:13

Just playing around.

bhauman22:07:28

are you on a node project?

eggsyntax22:07:07

Was rewatching Stu's repl-driven development talk & he was mentioning the way to create a macro that would give you the classic break-to-repl functionality, and I was idly wondering if I could make that work in cljs as well.

bhauman22:07:08

so CLJS doesn't have eval and that's a big blocker

eggsyntax22:07:21

Oh, right. Of course facepalm

bhauman22:07:42

macros run in Clojure space

bhauman22:07:03

unless you are in self host, and then it gets funky, I haven't really looked into it

eggsyntax22:07:10

Also of course facepalm

eggsyntax22:07:30

I don't typically mess with anything deeply along these lines on the cljs side, only in clj.

eggsyntax22:07:31

Thanks Bruce, appreciate it!

bhauman22:07:47

no worries, I hope things are going well for you 🙂

eggsyntax22:07:18

Very! Just accepted a job offer last night from these folks, and I'm pretty psyched about it 😄 😄 😄 https://democracy.works

eggsyntax22:07:31

Hope things are well for you too 🙂

bhauman22:07:45

Yeah I love that mission!!!

❤️ 4
bhauman22:07:11

they using clojure?

bhauman22:07:52

yeah me too

thiru22:07:17

@bhauman Just throwing it out there if you'd be willing to come to Toronto we have a job opening for a senior dev. We're mostly C# but I've been bringing in Clojure slowly. And our team has 20% time.. potentially more in the future 🙂

thiru22:07:11

Would you consider it if it were remote? We have some on our team but boss prefers local. But for a dev of your calibre we can definitely consider I think

thiru22:07:38

Cool no worries.. don't blame you at all! C# sucks 🙂

thiru22:07:16

Thanks @kwladyka ... I'm using Vim + vim-fireplace + Figwheel-main + tools.deps

thiru22:07:01

I'm not a total noob. I've been using (JVM) Clojure for a few months but trying to add in CLJS now

thiru22:07:50

I've had Vim + vim-fireplace + nREPL + tools.deps working good for that. But now adding CLJS I'm not so sure how to easily fit it in

thiru22:07:52

The new tool in my chain really just being Figwheel. Right now I'm running Clojure and ClojureScript REPLs in two different terminals (which I don't mind)... but how to connect both terminals to a single vim-fireplace?

bhauman22:07:29

@thiru0130 I don't use vim or vim fireplace

bhauman22:07:24

but it should work like this

bhauman22:07:08

start a Clojure nREPL from VIM like usual, if you only know how to do this wil lein then I reccomend that you use figwheel.main from lein for now to get started

bhauman22:07:16

make sure you have piggieback in your dependencies then call (figwheel.main/start "dev") if dev is your build name

thiru22:07:22

Thanks @bhauman - so I got that far and I can communicate to Vim in CLJ and CLJS code.. but how can I switch back to the CLJ repl in the terminal? It seems that once I run (figwheel.main/start "dev") I'm stuck in CLJS land?

thiru22:07:23

Is it possible to do this, or would I have to have two separate REPL/terminal instances?

bhauman22:07:46

I'm not sure of the capabilities of fireplace

bhauman22:07:25

but yes right now there is no way to run figwheel main separately and then attach a REPL to it

bhauman22:07:37

this is a planned feature

thiru23:07:47

Ahh right ok. At least I'm not missing anything then. I can wait. Thank you!

scknkkrer23:07:00

Does anyone have exprienced AWS Lambda with clojurescript ?