Fork me on GitHub
#clojurescript
<
2016-06-13
>
rnandan27305:06:42

Has anybody used datascript with re-frame. Is is possible to detect datascript events to propagate changes using the reaction / subscribe / pattern?

danielcompton05:06:54

@rnandan273: try in #C073DKH9P or #C07V8N22C

rnandan27305:06:29

@danielcompton: I am trying to integrate datascript with a re-frame based app, there is a library called posh, is that the only way to use?

oluwaseun05:06:47

Hello! I am using figwheel to build a cljs app. I want my client side js to be able to launch scripts and access (read/write) files on the local machine. I (think I) know I can achieve this with chord library using websockets, but I was wondering if anyone knows of perhaps a simpler way or any other alternatives. Or maybe chord is the best option? How would you do this? Thank you for time 🙂

bensu06:06:16

@oluwaseun: if it is meant to be a desktop app, electron might save you the trouble of having an http server

anmonteiro11:06:45

@bhauman: little piece of feedback about figwheel 0.5.4. I have a library that reads a custom CLJS compiler option, :css-output-to. Figwheel 0.5.4 hard errors on this compiler option with the following:

The key :css-output-to is spelled wrong and is mostly likely in the wrong position.
 It should be probably be spelled :output-to
this makes it impossible to use figwheel with such library

bhauman12:06:02

@anmonteiro: cool, noted, adding arbitrary options to cljs compiler options is going to make it hard to provide comprehensive validation for people, we need a place to put arbitrary options on a build

bhauman12:06:36

@anmonteiro: my guess is that you are putting this at the same path level as :source-paths?

bhauman12:06:06

:css-output-to is a sibling of :source-paths?

anmonteiro12:06:15

@bhauman: nope, it’s inside :compiler

bhauman12:06:35

and this is a your library?

anmonteiro12:06:27

:css-output-to is an option that my library will look for, yes

bhauman12:06:34

if we allow arbitrary keys it makes it impossible to know if someone has misspelled a key

bhauman12:06:59

or if a key is unknown

anmonteiro12:06:22

@bhauman: I could probably use :closure-defines from now on, yes, but what about backwards compatibility?

bhauman12:06:48

I'm guilty of this as well

dnolen12:06:53

@bhauman: tools shouldn't care about unknown keys

dnolen12:06:07

We had this problem in ClojureScript and we backed it out

anmonteiro12:06:09

would you consider adding a knob to turn that check off?

bhauman12:06:48

@dnolen: i really hear you on that and figwheel was one of the tools that caused the problem

anmonteiro12:06:50

I think that + me adding a closure-define would solve the immediate problem

dnolen12:06:08

We just do levenstein distance on know keys and leave it at that

bhauman12:06:14

@anmonteiro: I'll certainly add an exception for that

bhauman12:06:04

@dnolen: and you fail? or warn?

dnolen12:06:31

Just warn if we find possible match

mfikes15:06:27

@bhauman: For reference, at worst, the compiler only ever warned about things (never balked), but what we did end up doing is drastically cutting down on the warning noise by backing out part of it. Here is the commit if it helps: https://github.com/clojure/clojurescript/commit/177b05fc5935c659e4829b7b1798e216b6797bec

mfikes15:06:11

@bhauman: IIRC, the Levenshtein distance had to be 3 or less to trigger a suggestion. So, in summary :css-output-to vs. :output-to skates by by one character diff.

rnandan27318:06:55

I am trying to use alandipart's local storage library as a backing db in re-frame, but the reactions don't seem to get triggered. Any pointers?

nathanmarz19:06:58

Having issues using macroexpand inside a macro used via ClojureScript

nathanmarz19:06:12

(defmacro foo [x]
  (println "Before:" x)
  (println "After:" (macroexpand x))
  )

(defmacro bar []
  `(+ 1 2))

nathanmarz19:06:41

Running (foo (bar)) at repl prints this:

cljs.user=> (foo (bar))
Before: (bar)
After: (bar)
Before: (bar)
After: (bar)
Before: (bar)
After: (bar)
nil

dnolen19:06:20

@nathanmarz: runtime macroexpand isn’t a thing

dnolen19:06:44

there’s just a simpler helper thing for when you are at the REPL

dnolen19:06:04

inside a macro

dnolen19:06:19

yeah I don’t know that we have a helper for that?

dnolen19:06:42

yeah we don't

nathanmarz19:06:35

I'll see if I can work around it somehow

henriklundahl19:06:38

I'm having problems with :foreign-libs being included in the JS in the wrong order. What could cause that? What should I check for?

henriklundahl19:06:41

This is my :foreign-libs vector:

[{:file "foreign-libs/cljsjs/react-with-addons/development/react-with-addons.inc.js"
                                   :provides ["cljsjs.react"]}
                                  {:file "foreign-libs/cljsjs/react-dom/development/react-dom.inc.js"
                                   :provides ["cljsjs.react.dom"]
                                   :requires ["cljsjs.react"]}
                                  {:file "foreign-libs/cljsjs/react-dom-server/development/react-dom-server.inc.js"
                                   :provides ["cljsjs.react.dom.server"]
                                   :requires ["cljsjs.react"]}]

henriklundahl19:06:05

ReactDom seems to get included first instead of React for some reason.

dnolen19:06:04

@henriklundahl: doesn’t cljs.react.dom.server need cljs.react.dom

dnolen19:06:18

if so then your provides and requires are not right yet

henriklundahl19:06:27

No, I don't think so.

dnolen19:06:54

that’s my only guess then

dnolen19:06:52

@nathanmarz: you have cljs.analyzer/macroexpand-1

dnolen19:06:30

that hardwires you a bit to analyzer, but that sig probably not going to change

nathanmarz19:06:07

@dnolen thanks, I'll look into that

dnolen19:06:32

@nathanmarz: you need to pass &env as the first argument, form as the second one

nathanmarz19:06:35

@dnolen: yea it works. Will try to make a macroexpand-all based on this

rohit20:06:02

@henriklundahl: are you experiencing this issue while using cljsjs/react-dom and/or cljsjs/react-dom-server package from clojars?

kauko20:06:11

(re-find #"(?i)foobar" "baz baz Foobar") => "Foobar", (clojure.string/replace "baz baz Foobar" #"(?i)foobar" "match") => "baz baz Foobar". The case insensitive flag works for clojurescript's re-find, but not for str/replace. Is this a known bug?

dnolen20:06:04

@kauko: some simple things work but it’s not a goal to make most things work

dnolen20:06:17

Java regular expressions and JavaScript regular expressions are quite different

dnolen20:06:55

so this may be a simple bug or just a platform difference we do not intend to address - that should be sorted out first which it actually is

henriklundahl21:06:12

@rohit: Yes, but I have extracted the JS from the jar files to try to get it to work that way, but unsuccessfully so far.

henriklundahl21:06:09

The root reason was that I wanted to use the React test utils.

henriklundahl21:06:54

Under simple and advanced optimizations, the minified JS is used, however, and the test utils have been excluded from there.

dnolen21:06:22

@henriklundahl: it’s possible you found a bug but would would want to see something minimal that doesn’t require any libs

dnolen21:06:21

that is if there’s an issue, it should be reproducible outside of your specific case here

henriklundahl21:06:11

Yes, I understand that. If I would want to try to debug it, where should I look?

rohit21:06:50

@henriklundahl: if you are trying to use react-with-addons package and you don’t want to package it yourself, have a look at this: https://clojurians.slack.com/archives/cljsjs/p1465368980000021

rohit21:06:16

what you are trying may have an issue as @dnolen suggests. so thats also worth investigating.

dnolen21:06:05

@henriklundahl: one thing we do is dump a Google Closure dependency graph file - out/cljs_deps.js

dnolen21:06:25

you should check that things in that file respect what you’ve defined

dnolen21:06:13

then you should make sure that there are no errors in any of these React JS files (by loading them independently)

dnolen21:06:23

if you’re using dom.server I’m assuming you are doing something with Node.js?

henriklundahl21:06:32

Ok, will check. I believe reagent requires it, but perhaps I can do without it? I don't do JS server rendering.

henriklundahl21:06:17

@rohit: That's the way I started, but the React test utils are excluded from the minified JS and the minified file is used when using simple or advanced optimizations.

rohit21:06:12

@henriklundahl: let me quickly check that. i have a working setup of react-with-addons

henriklundahl21:06:46

@dnolen: What do you think of the idea of adding a flag for whether the minified JS should be used?

dnolen21:06:09

@henriklundahl: in theory already possible

dnolen21:06:15

you can override

dnolen21:06:35

you don’t need to dump that stuff into a separate directory

dnolen21:06:17

er, hrm actually maybe you do, we don’t have literals for urls

dnolen21:06:28

in anycase that should work

dnolen21:06:54

we index on :provides

dnolen21:06:19

so if you :provides something already provided by a deps.cljs your thing will take precendence

rohit21:06:43

@henriklundahl: thats true. React.addons.TestUtils does get compiled away in the minified build. I guess thats by design by the react package maintainers

henriklundahl21:06:51

I tried to override deps.cljs as well, but that didn't work either.

dnolen21:06:07

@henriklundahl: well I know people depend on it

dnolen21:06:18

so “didn’t work” needs to be narrowed down to something specific

dnolen21:06:38

the first thing to do is stop bothering with all this stuff

dnolen21:06:48

just make trivial foreign dep and see if you can get that to work first

henriklundahl21:06:04

As long as it's just one it works fine.

dnolen21:06:22

so demonstrate something minimal

henriklundahl21:06:24

I'll try to narrow it down.

dnolen21:06:26

you don’t need cljsjs.react to do this

dnolen21:06:35

just make a foreign dep file a, b, c and show that it doesn’t work

henriklundahl21:06:06

Yes, I'll try.

dnolen21:06:15

if we have that - then we can fix and easily make a test case

kgzm22:06:18

Is there some way to override the node binary name that cljs.repl.node/repl-env uses?

dnolen23:06:30

@kgzm: :node-command

kgzm23:06:00

@dnolen: I was looking into that but unless I'm missing something the options that get passed to cljs.repl.node/repl-env actually don't make it past cljs.repl.node/repl-env*, the host and port are sifted out.

dnolen23:06:49

So just a bug then, patch welcome

kgzm23:06:01

I'd love to.