Fork me on GitHub
#clojurescript
<
2017-02-05
>
pupeno01:02:00

@weavejester is this how it's supposed to be used: (cljfmt.core/reformat-form '(let [a 1 b 2] (+ a b)))

weavejester02:02:46

@pupeno typically you work off a string that’s formatted in some way already. cljfmt corrects any problems with the formatting.

weavejester02:02:00

@pupeno If you want to format from scratch, zprint might be a better option.

Jon04:02:08

I prototyped a virtual DOM for Three.js in cljs, not powerful enough but at least works https://www.youtube.com/watch?v=5NHYiW2Y-Jg

isaac05:02:58

Can I extend-type for all seq data type, eg. (extend-type ISeq SomeProtocol ...) I tried, But not work.

dvingo05:02:34

I believe it's because ISeq is a protocol and not an acceptable argument type

dvingo05:02:37

here's the doc:

dvingo05:02:46

clojure
dev:cljs.user=> (doc extend-type)
-------------------------
cljs.core/extend-type
([type-sym & impls])
Macro
  Extend a type to a series of protocols. Useful when you are
  supplying the definitions explicitly inline. Propagates the
  type as a type hint on the first argument of all fns.

  type-sym may be

   * default, meaning the definitions will apply for any value,
     unless an extend-type exists for one of the more specific
     cases below.
   * nil, meaning the definitions will apply for the nil value.
   * any of object, boolean, number, string, array, or function,
     indicating the definitions will apply for values of the
     associated base JavaScript types. Note that, for example,
     string should be used instead of js/String.
   * a JavaScript type not covered by the previous list, such
     as js/RegExp.
   * a type defined by deftype or defrecord.

  (extend-type MyType
    ICounted
    (-count [c] ...)
    Foo
    (bar [x y] ...)
    (baz ([x] ...) ([x y & zs] ...))

etherfuse05:02:54

anyone have an example of fake http requests with mount?

etherfuse05:02:13

basically trying to run acceptance tests, and specify what I’m expecting

dvingo05:02:17

ISeq is a protocol:

dvingo05:02:31

`dev:cljs.user=> (doc ISeq) ------------------------- cljs.core/ISeq Protocol Protocol for collections to provide access to their items as sequences. `

etherfuse05:02:18

I must be thinking of this wrong but isn't’ there a library for clojurescript that I could use something like (fake-routes ....)

etherfuse05:02:37

then write my tests and run them with doo

ul07:02:05

Hi! I've encountered weird compiler behaviour with :pseudo-names true. This code https://github.com/ul/carbon-snake/blob/master/src/carbon_snake/core.cljs#L130-L145 is transformed into that js https://gist.github.com/ul/fc23aee02cb5769f4c542be13ef32a16 Problem is that this var https://gist.github.com/ul/fc23aee02cb5769f4c542be13ef32a16#file-core-js-L68 always stays null because $temp__6753__auto__$jscomp$57$$ is undefined. In development mode and :advanced compilation everything works perfectly. Code becomes broken when :pseudo-names true is enabled.

ul07:02:09

@dnolen ^^^ I suspect a bug, but don't know how to better report in this case.

pbaille10:02:10

Hello, cljs.core/satisfies? is a macro, is there an equivalent function in core?

pesterhazy10:02:23

((fn [x] (satisfies? cljs.core/IFn x)) {})
`

pbaille10:02:58

I would like the protocol to be dynamic

pesterhazy10:02:12

that may not be possible

pesterhazy10:02:16

Don't take my word for it

pesterhazy10:02:20

are you aware of instance??

pbaille10:02:40

I will try that

pesterhazy10:02:25

that doesn't seem to be dynamic either

pesterhazy10:02:10

you could always check manually: (= cljs.core/PersistentArrayMap (type {}))

pbaille10:02:44

yes doesn't seems to work for me

pbaille11:02:58

I'm a bit puzzled by this:

pbaille11:02:10

(defprotocol Yo (yo [x])) (extend-protocol Yo IMeta (yo [x] "IMeta yo")) (yo []) ;=> Boom!

pbaille11:02:37

Doesn't it makes sense to do this?

thheller11:02:46

@pbaille IMeta is a protocol, you cannot extend a protocol on a protocol

pbaille11:02:42

yes I know this is a protocol, but I'm wondering why it doesn't make sense to extend a protocol to another

pbaille11:02:25

the more I think about it the more dispatching issues I can think of

pbaille11:02:34

so yes, it is probably a bad idea

pbaille11:02:35

I should use multimethods for thing like that and use prefer function to resolve dispatch ambiguity

thheller11:02:42

or extend your protocol onto the types you want it to support

thheller11:02:24

you can use extend to make that a bit easier on the code

thheller11:02:33

ie. not repeating the implementation

thheller11:02:49

forgot the correct syntax though

pbaille11:02:28

Yes sure, I know. thank you for your help

pupeno12:02:26

@weavejester: ah, ok. In my case, I need to run some code and display it too, so, I just have the code.

pupeno12:02:40

@emccue are you still trying to achieve all the URLs working? I think I have the solution.

emccue12:02:49

I had thrown in the towel for now.

emccue12:02:57

What is your solution?

pupeno12:02:38

I created a library called Free Form to make forms with Reagent and Re-frame and to play with it and display it's capabilities, I created a project called Free Form Examples: https://github.com/pupeno/free-form-examples

pupeno12:02:25

It started out of a re-frame template but I normally modify them quite a bit (I like grouping subscriptions, events, functions, views etc by component not by type).

pupeno12:02:50

But, if you look at the Clojure side, instead of the single empty file, it has this: https://github.com/pupeno/free-form-examples/blob/master/src/clj/free_form_examples/core.clj

pupeno12:02:07

And this bit you can ignore because it's just to serve the app in production, when I deploy to Heroku: https://github.com/pupeno/free-form-examples/blob/master/src/clj/free_form_examples/core.clj#L19-L21

pupeno12:02:52

Maybe I should write a blog post about it.

pupeno12:02:30

Feel free to check out the app and run it. It doesn't require any database or anything like that, so, it should be very straightforward and you can play with it and see whether it behaves the way you want.

emccue12:02:36

That sounds great, I'll check it out after work.

emccue12:02:44

Thank you for your time

pupeno12:02:03

Happy to help.

grounded_sage12:02:47

@rauh I managed to fix the styling issues. I used System Properties instead of an atom.

Aron12:02:59

what is a nice way to write this function in clojurescript? (R is ramda.js) const touches = R.curry((node, link) => link.source == node || link.target == node )

Jeremie Pelletier15:02:56

is there a way to use “resources/public/main.cljs.edn” with boot-reload? This creates a warning “adzerk.boot-reload.public.main contains a reserved JavaScript keyword” that I can’t seem to work around - I’d very much like to keep “resources/public"

juhoteperi16:02:04

@lambdacoder It is just a warning, you can still use it, and the next version of boot-reload will fix this.

Jeremie Pelletier16:02:21

that warning prevents reloading from working tho

Jeremie Pelletier16:02:43

boot-reload injects its init ns and detects changes correctly, but they arent pushed to the browser - the warning is

juhoteperi16:02:47

Oh, didn't notice that when investigating it.

juhoteperi16:02:19

one sec, I'll push a snapshot with a fix

Jeremie Pelletier16:02:25

I just noticed 0.5.1-SNAPSHOT seems to fix it, but its not in clojars yet

Jeremie Pelletier16:02:43

awesome, thanks a lot 🙂

juhoteperi16:02:21

Okay, snapshot should now be deployed. If you can confirm it works, I'll do a release right away.

Jeremie Pelletier16:02:50

hrm, "Could not find artifact adzerk:boot-reload:jar:0.5.1-SNAPSHOT in clojars (https://repo.clojars.org/)” but I see it on http://clojars.org

Jeremie Pelletier16:02:19

I had tried to get that jar a few minutes ago, cache issue?

juhoteperi16:02:01

Perhaps a local cache issue, should be available in repo: http://repo.clojars.org/adzerk/boot-reload/0.5.1-SNAPSHOT/

Jeremie Pelletier16:02:42

ah local cache indeed, it existed in my ~/.m2 as a glorified 404

Jeremie Pelletier16:02:14

well even after completely erasing ~/.m2 the jar is still not found, ill install manually

Jeremie Pelletier16:02:45

mvn won’t install the jar either: mvn install:install-file -Dfile=boot-reload-0.5.1-20170205.160151-1.jar -Dpomfile=boot-reload-0.5.1-20170205.160151-1.pom Failed to execute goal org.apache.maven.plugins:maven-install-plugin:2.4:install-file (default-cli) on project standalone-pom: The artifact information is incomplete or not valid:

Jeremie Pelletier16:02:11

which is odd cause the fields it says are missing are in the pom file

juhoteperi16:02:06

Odd. I removed the version from my ~/.m2 and it got successfully downloaded from Clojars.

Jeremie Pelletier16:02:02

and now it seems solved magically heh, rerunning my boot dev task downloaded it

Jeremie Pelletier16:02:39

well I deleted the resolver-status.properties file it had recreated

Jeremie Pelletier16:02:02

warning is gone and reloading works !

juhoteperi16:02:01

Great, deploying proper release now

noonian21:02:55

I ran into this issue when using the reloaded workflow with tools.namespace and using cljc files: http://dev.clojure.org/jira/browse/TNS-45?focusedCommentId=44148. I’m looking for opinions on how to support the reloaded workflow, cljc files, and serving resources from the classpath for uberjars. I’m currently favoring serving from the filesystem during development to avoid classpath issues with tools.namespace, and using a different handler in production to serve resources from the classpath.

thheller22:02:57

FWIW serving assets via the filesystem is the better choice for dev and production

thheller22:02:13

as you can deploy new CLJS without restarting your entire server 😉

thheller22:02:11

the compiled output should never be on the classpath

noonian22:02:55

Yeah. For toy projects I appreciate having everything self contained in a single jar. Compiling cljs output to resources/public is also the default configuration in most cljs app templates I’ve seen.

thheller22:02:38

yeah unfortunately

thheller22:02:12

but for tools.namespace

thheller22:02:44

there is a function that lets you control which directories are reloaded .. set-refresh-dirs! or something like that

noonian22:02:42

Yeah, I’ve had some success with that. I think an exclude-refresh-dirs! is closer to what is needed since you know where the compiled output is going but often want other resources to be refreshed.

noonian22:02:06

Sounds like avoiding the classpath is the correct approach though

thheller22:02:27

you can also create a :uberjar profile in lein

thheller22:02:54

and add the directory your output goes to, this way it won't be on the classpath but still in the uberjar

noonian22:02:38

Thats perfect for me, thanks!