Fork me on GitHub
#clojurescript
<
2016-06-02
>
bhauman00:06:22

I keep wanting to refactor the cljs.repl/repl* code into a constructor for the functionality (read, eval, print, prompt, etc) and the bundled environment data and separate it from the loop. This would be a boon to piggieback with it's ugly duckling "setup a repl on every eval" behavior. There is also the possibility of factoring out the setup code into a group of functions that can be re-used. I guess the point is that the setup code is very valuable and it would be nice to have a convenient way to construct an eval function, or a type that we can call eval on.

debug02:06:36

(.then (get-json-promise) #(js/console.warn (.-url (first %))))
(.then (get-json-promise) (fn [data] (js/console.warn data) (map #(js/console.warn (.-url %)) data)))
With map nothing happens. Why? first works however.

noonian02:06:53

@debug: map returns a lazy seq. If you want side effects you probably want doseq. See this stackoverflow for an example: http://stackoverflow.com/questions/21069188/how-do-i-perform-a-function-with-side-effects-over-a-vector

debug02:06:13

@noonian: Thank you very much! 😄

pesterhazy10:06:04

@debug, as a quick fix, you can also replace map with run!

bendlas11:06:51

[figwheel "0.5.4-SNAPSHOT"] gives me an error about :compiler being a wrong configuration key. Has something changed, or did I do this wrong all along? @bhauman ?

bendlas11:06:38

can't find anything in CHANGES about it

bendlas11:06:12

replacing it with :build-options (as indicated in the error message) worked though. To be clear, I'm talking about running figwheel-sidecar.repl-api/start-figwheel!. With 0.5.3, the :compiler key worked just as well, and I don't remember seeing a warning about it.

bhauman11:06:25

@bendlas: I really had to choose one or the other.

bhauman11:06:11

Unfortunately it may change back to compiler in the future to stay consistent. 😞

bendlas11:06:23

fine by me, I just wasn't aware of the alternative.

bendlas11:06:39

does cljsbuild support both?

bendlas11:06:03

well, with such good error messages, it's no biggie

bendlas11:06:47

but you might also want to log them, because I didn't immediately discover it, due to running start-figwheel! in a future

bendlas11:06:11

and by the way, big Thank you and big Up for figwheel 🙂

dnolen12:06:39

@bhauman changing cljs.repl/repl* just isn’t going to happen, all that stuff is more or less frozen in stone at this point.

dnolen12:06:23

making some new thing that piggieback can use is the only thing that would be considered

bhauman12:06:31

that works 🙂

dnolen12:06:33

the surface interface of what exists will not change

bhauman12:06:46

oh absolutely

debug12:06:51

@pesterhazy thanks! Will try that

bhauman12:06:01

I would never change the surface interface

bhauman12:06:04

a constructor function that takes ReplEnv and returns an eval method or something like that was all that I was thinking of

dnolen12:06:17

there are some subtle problems here - mostly around dynamic binding

dnolen12:06:44

particularly *unchecked-if* which works across multiple forms

dnolen12:06:15

so the person creating such a ReplEnv has to know about it and handle it

bhauman12:06:15

alrighty, I will keep that in mind

bhauman12:06:25

when I look at it

bhauman12:06:06

right now piggieback is pretty damn slow and lots of people are using it

dnolen12:06:45

yeah, I can imagine but I already looked at that problem once

dnolen12:06:50

not going to look at it again

bhauman12:06:54

oh for sure

bhauman12:06:35

I was planning on looking at it.

dnolen12:06:31

also it’s not clear to me why it needs to be done at this level at all

dnolen12:06:04

i.e. why not put the framing stuff around Socket REPL connected to a ClojureScript REPL and separate all these problems

bhauman12:06:14

I have been thinking about that as well.

bhauman12:06:47

And I get that approach completely. There is no argument here, I do think that approach can lead to tools opting to parse strings for errors and warnings and such.

dnolen12:06:16

@bhauman: I also don’t see why you need to be thinking about this 😉

dnolen12:06:48

the tools to fix all these problems have been sitting around for a long time now, anyone can work on this - especially people without full plate of tooling work

bhauman12:06:05

this is true 🙂

dnolen12:06:09

yeah the last commit to piggieback was in 2015

dnolen12:06:24

this means no one is working on the problem

bhauman12:06:43

I was thinking I could fix it pretty easily

dnolen12:06:56

if you’re annoyed your REPL is slow it is time to lift a finger

bhauman12:06:30

its not "that" slow, but its strangely latent

dnolen12:06:43

well not strangely

dnolen12:06:56

Clojure doesn’t construct anything when creating the evaluation environment

dnolen12:06:04

ClojureScript does a ton of work

bhauman12:06:08

for known reasons

dnolen12:06:28

but as I said this isn’t the root problem

dnolen12:06:33

the root problem is piggieback

dnolen12:06:50

and stubborn need to recreate the environment

dnolen12:06:50

I don’t think trying to work around it desirable at all

dnolen12:06:11

adding stuff because one tool has a questionable implementation seems ill advised

rui.yang12:06:39

anyone using secretary for frontend routing here? help needed

dnolen12:06:32

a likely simpler idea - nREPL / Socket REPL adapter

dnolen12:06:53

then you stop caring what ClojureScript does

dnolen12:06:27

case in point

dnolen12:06:32

when I run Figwheel on a remote box

dnolen12:06:38

how long does it take to get a new REPL?

dnolen12:06:47

instantaneous

rui.yang12:06:00

how to make (secretary/dispatch! "/login”) to change URL? changing URL will fire dispatch and according handler. but manually fire dispatch won’t change browser url 😞

bhauman12:06:47

@dnolen: currently grokking the different implications of this... will let it ruminate

bendlas12:06:37

@rui.yang: there might be another way, but I just .setToken on the goog.history.Html5History

bendlas12:06:09

this will trigger the routing though so be sure to break the cycle as appropriate

dnolen12:06:48

@darwin @bhauman so something else that’s been on my mind related to tooling - it seems the need to inject something for setup into the build is pretty high

dnolen12:06:08

things that would otherwise require the user writing error prone connection code etc.

dnolen12:06:51

so I’m open to the idea of making some standard way to get thing X loaded and setup before user code

bhauman13:06:13

oh like injecting figwheel client

dnolen13:06:14

I know people already have workaround or what not, but if people have some strong opinions about how this should be handled - I’m listening

bhauman13:06:07

If you create an issue ping me. I'll look at what figwheel is doing and see if I can help.

rui.yang13:06:49

@bendlas: thanks for the tip

rui.yang13:06:53

will try it out

bhauman13:06:09

really like the idea though

rui.yang13:06:09

@bendlas: what I want to do is to switch pages in my SPA. the correct way is call History.setToken to trigger secretary/dispatch!, instead of calling secretary/dispatch directly. thanks for the tips

gowder13:06:27

Ok, I just gotta come in here to say how much I love cljs and reagent. Trying it for the first time to muck around on the front end, and I love how the combination of cljs and react just basically abstracts away all the ugly of dom manipulation. Such happy.

pvinis13:06:47

hello. im trying the modern cljs tutorials

pvinis14:06:00

and i get this message

pvinis14:06:38

what exactly does that mean

anmonteiro14:06:20

@rui.yang: you might also want to have a look at pushy, which integrates goog.History with well-known routing libs

bendlas14:06:19

@bhauman: figwheel fails when trying to show the warning dialog for warninged code: when calling format-line from heads-up/display-system-warning, a map gets passed, and subsequently goog.string.indexOf gets called on that

bhauman14:06:07

hmmm, did you do a lein clean? Just making sure before I check it.

bhauman14:06:18

and reload the browser?

bendlas14:06:03

let me try that lein clean real quick

bendlas14:06:30

nope, str.indexOf is still not a function

bendlas14:06:46

I'm using it with devtools though

bendlas14:06:18

commented it out, reset-autobuild still there

bhauman14:06:39

display-system-warning isn't called with a map

bhauman14:06:51

The old display-warning composed over display-system-warning. it doesn't do that anymore.

bendlas14:06:34

strange, i see it called with a map with :ns :file :extra :column .... in my debugger

bendlas14:06:42

with current snapshot

bhauman14:06:12

have you tried it without dirac?

bendlas14:06:27

no dirac, just devtools

bendlas14:06:56

i commented it out (the require too), did a reset-autobuild and it persisted.

bendlas14:06:00

rechecking ....

bendlas14:06:15

i do run figwheel-sidecar from code, though

bhauman14:06:41

yeah you are running the old client code for sure

bhauman14:06:28

old client code with new sidecar messages, won't work

bendlas14:06:42

ok, target folder is gone

bendlas14:06:07

figwheel-sidecar version is 0.5.4-SNAPSHOT

bendlas14:06:26

starting up the server .,..

bendlas14:06:13

hold it, deleting figwheel from .m2, restarting ...

bendlas14:06:35

oh ... snapshot depends on 0.5.3-2

bendlas14:06:40

just saw it in the download

bendlas14:06:57

overriding figwheel version in project.clj too

bhauman14:06:58

nope, you are depending on 0.5.3-2

darwin14:06:32

@dnolen: that would be great, but I think the problem is two fold: 1) how to make sure init code for different tools runs in particular order before user’s own code which runs last (also the user should be able to specify that order explicitly if needed) 2) how to provide configuration to individual tools I think the first problem would be solvable by allowing compiler option :main to accept a list/vector of namespaces. cljs-devtools would provide a special “bootstrapping” namespace which would contain (devtools/install!) call, people would put it there before their own namespace(s). I think this is something @thheller already proposed in some JIRA ticket. The second problem would be more work. I would like to see something like “environmental config” which could be passed in compiler options and tools could configure themselves based on it. Right now, the best practice for cljs-devtools installation is described here: https://github.com/binaryage/cljs-devtools/blob/master/docs/install.md#dev-builds And the tool can be configured by altering default prefs before calling (devtools/install!) https://github.com/binaryage/cljs-devtools/blob/master/src/devtools/prefs.cljs

bendlas14:06:48

no, i depend on figwheel-sidecar 0.5.4-SNAPSHOT, which in turn depends on figwheel 0.5.3-2 apparently

bhauman14:06:08

it doesn't

bendlas14:06:59

ok sorry, my dev meta-dependency depends on it and leiningen chose that one, sorry ...

bendlas14:06:31

classic transitive dependency fail 😞

bendlas15:06:02

that works now

bendlas15:06:13

the new dialog is really shiny

richiardiandrea15:06:33

@darwin: just fyi in case you don't already, boot-cljs does exactly what you said, the same convention could be brought to core: https://github.com/adzerk-oss/boot-cljs/wiki/Usage#multiple-builds

dnolen15:06:05

@darwin not actually interested in 1) at all

dnolen15:06:08

use component

bhauman15:06:14

@dnolen: @darwin a thunk of code custom init code that runs before :main is required, could go a long way, this allows for a great deal of expression

dnolen15:06:44

I only care about simple cases where ordering isn’t going to matter

dnolen15:06:22

REPLs / browser dev stuff

dnolen15:06:34

anything more complicated we’re not going to deal with

darwin15:06:37

hm, “use component” means “force user to use component”, because me using component does not help if user is not starting his app via compoenent model and integrate my component into his components deps properly

dnolen15:06:00

if you need component use component

dnolen15:06:12

every tool should work as lib so user can solve their own problems

dnolen15:06:40

the only thing I’m interested in is for newbies who want to just try something

dnolen15:06:01

they can copy and paste some simple build config - and we provide a easy hook for these basic cases

dnolen15:06:09

anything more than that - no interest

darwin15:06:09

btw. just curious, would you consider forking cljs-devtools into cljs.devtools namespace (a new project) and make it part of “out-of-box” clojurescript experience? I think it got mature enough and I would be willing to make changes to make that happen

dnolen15:06:45

@darwin that’s interesting - but I think tooling stuff probably should evolve freely outside of the various restrictions around official projects

dnolen15:06:01

as far as I can tell - it takes a long time to know what is or isn’t going to work

darwin15:06:44

sure, no problem, I’m quite happy with current setup

bhauman15:06:46

@darwin: I've been thinking about including it with figwheel as configurable option

bhauman15:06:24

I need to use it for a bit first

darwin15:06:50

@bhauman: yeah, anything which reduces friction for new users sounds good to me, figwheel is first thing people install and if they get cljs-devtools for free, better

bhauman15:06:22

yeah as long as your happy with it, I'll explore it

darwin15:06:01

but you will still have the problem “how to run devtools/install! before any user’s code”, without user’s assistance, you cannot do that AFAIK

bhauman15:06:18

I can do it

darwin15:06:31

how? via lein plugin?

bhauman15:06:31

figwheel already injects code

bhauman15:06:59

it injects itself in builds with :figwheel true

bhauman15:06:09

so I just inject a little more

bhauman15:06:15

its kinda perfect

darwin15:06:23

another topic: I want to integrate figwheel's nREPL with Dirac soon, something along these lines: https://github.com/binaryage/dirac/blob/master/docs/integration.md I think it should work in theory even now. But I want to make sure, the new improved error/warnings could be displayed nicely in Dirac when joined with figwheel REPL

darwin15:06:26

the idea would be to start Figwheel with nREPL as usual, but include dirac nREPL middleware and then join it with Dirac REPL as described in the document

ericfode16:06:09

When running tests that use cljs.spec (using lein-doo) It prints the newlines as escaped in the validation errors, how do i tell it to print them instead?

kingoftheknoll17:06:01

I’m making a website plugin system. [cljs.core, my-base-code.core -> js] <<load scripts << [p1.cljs-> js] & [p2.cljs -> js] Is it possible to compile cljs into a js file without including dependencies of require’d namespaces. So I can then just include the plugin js files and they will work because cljs.core and other libs will already be loaded. I believe LightTable does something similar for it’s plugins, I’m just not sure if this is a compiler option or more like defining my cljs code as externs… Any advise would be appreciated!

dragoncube17:06:11

Is something changed since this thread started and where is a way to simplify patterns? https://groups.google.com/forum/#!topic/clojure/13gOQgzGEMk

dnolen18:06:06

@dragoncube: nothing has changed

mathpunk18:06:05

I’m trying to use @ra’s clojurescript-npm to write a script. The following does what I expect if entered line by line into their cljs repl:

mathpunk18:06:49

But this next file, in js, is not the right way to run it as a script — it exits with no output:

mathpunk18:06:14

I’m curious where my mental model is failing

pat19:06:27

@mathpunk looks like you need to send the data somewhere

pat19:06:53

Try process.stdout.write(result);

mhr20:06:19

I'm having trouble finding a good explanation for how Hoplon and Reagent/Re-frame compare. I know Hoplon uses a "spreadsheet" metaphor with Javelin and doesn't use React, and Reagent uses FRP and React, but spreadsheets are sort of FRP, aren't they? How does the metaphor diverge? I want to make an app where much of the code I could reuse for the web, my phone, and the desktop, though this will most likely be a desktop-first app via Electron. I want to make a personal knowledge base (https://en.wikipedia.org/wiki/Personal_knowledge_base), so I want to be able to query and explore a multimedia graph database rendered in canvas or WebGL (I'm not sure of the GUI side yet, but the data structures side is pretty well-defined for me). I want to have the database be immutable and versioned, so I've been looking into using DataScript as the base for my database. How would DataScript fit into Hoplon or Reagent? Can you help me understand the pros and cons or differences between Hoplon and Reagent for someone who hasn't used React or ClojureScript before? I use JS a lot, but I don't have any real experience with the React or ClojureScript ecosystems nor even Clojure, so I don't quite know why I would want CLJS-flavored React any more than I know that I would want Javelin. I apologize for requesting such a comprehensive explanation from such ignorance. There's so much information to understand that it's difficult for a newcomer like me to make sense of it and make a good judgment on which framework/library is best for me. I have dabbled in different Lisps but haven't used any for real projects, though I've made a Lisp interpreter. I say this so you realize I'm not a complete newbie when it comes to Lisps in general, though I'm definitely a newbie to Clojure(Script).

gamecubate20:06:55

Hi everyone. New at reagent. I defined a component, giving it a :name prop. Something like

(defn my-comp [name] [:h1#title {:name name} name])
. Elsewhere in code, I setup a click event listener for that component:
(dommy/listen! (dommy/sel1 "#title") :click clicked)
. How do I access the :name prop from inside the event handler?
(defn clicked [] ...)

dnolen20:06:48

@gamecubate: there is a #C0620C0C8 channel

dnolen20:06:20

@mhr: there’s a #C08BDAPRA & #C0620C0C8 channel, probably best to ask that question in the respective places

gamecubate20:06:35

Yes I saw and (double) posted (here). Not so deep on Slack yet. Thanks will keep it to one channel.

gamecubate20:06:53

<switching over to reagent>

dnolen20:06:43

@ericfode: might need @bensu to chime on that when he has time

noonian20:06:50

@gamecubate: you probably want to attach your event listeners through react/reagent by providing an :onClick property (might be :on-click in Reagent). If you do it that way you will already have the :name property in scope.

gamecubate20:06:55

Understood but I want the handling to be done by a third-party, a mediator, who knows whether or not component clicks should be processed or, depending on some app-state property, ignored.

mhr20:06:00

thanks @dnolen, I figured I'd get more eyeballs here, but I'll cross-post there too

volrath20:06:20

I have a quick noob question. I think it's a boot-reload question but I'm not 100% sure so I'll post here, please let me know if there's a better channel for it. I'm using boot on this small project and I have several modules, let's say I have core.cljs which imports module A which imports module B (core <- A <- B.) I make a change in B and only that module gets reloaded, but I want the reloading to "bubble up" through the modules up to core.cljs, is that possible? I want this because core.cljs has a "renderer" that needs to be reload in order for me to view the changes made in any of its submodules.

volrath20:06:30

maybe I should use something like on-jsload?

juhoteperi20:06:31

@volrath: Yes, unfortunately you currently need to use on-jsload to call the renderer, because boot-reload doesn't use dependency graph to reload dependent namespaces

volrath20:06:56

noted, thanks for the quick reply 🙂

bensu20:06:22

hey @dnolen ! @ericfode I haven’t tried cljs.spec yet. Do you mind filing an issue on doo so that I update to the latest cljs version and make sure it properly works?

dnolen23:06:31

there was a bug with multi-arity fn spec verification caught by Oliver George now fixed in master

dnolen23:06:35

if people have some time please give it a spin

dnolen23:06:47

would like to cut a release tomorrow with this fix