Fork me on GitHub
#clojurescript
<
2016-01-26
>
euandreh04:01:11

Hi, everyone. Just joined the channel =]

euandreh04:01:35

Has anyone did some ClojureScript on Angular 2?

slipset09:01:18

I've been playing a little with planck these last couple of days, which has been quite fun, but there is one part of the story that I'm not totally comfortable with, and it's the dependency management.

slipset09:01:04

AFAIK you need to use lein unless you want to do dependency management by hand, which means you need to have java installed.

slipset09:01:48

Anyone have any thoughts on this?

martinklepsch10:01:46

@slipset: if you want to build an app or similar with clojurescript it will be hard to do so without Java and a build tool like Lein or Boot

martinklepsch10:01:57

@euandreh: most clojurescript people build stuff on top of react because it's a good fit for clojurescripts immutable data structures, because of that angular/ember and others are rather uncommon.

martinklepsch10:01:54

@euandreh: still probably there are people that have used cljs and angular, they're just not as many :)

jaen10:01:00

I know there was a Angular 1 library, but I didn't hear anything about Angular 2.

jaen10:01:25

Isn't it geared towards classes and typescript though? Using that with Clojurescript might be somewhat awkward.

slipset10:01:37

@martinklepsch: yes, and I guess building a buildtool in Clojurescript is a Yak too big to shave simple_smile

jaen10:01:46

But I would rather suggest at trying reagent + re-frame + cljs-ajax for example. Or om.next if you're feeling like it's a fit for your needs (it's more complex, but for a good reason tho).

andrewboltachev10:01:58

Hi. Is it possible to synchronize AJAX request with core.async somehow (taking into account <!! doesn't exist in CLJS)?

jaen11:01:56

Synchronise in what way? You mean make a synchronous AJAX request that returns the value instead of calling a callback?

grav11:01:37

what’s the best way of handling arbitrary precision numbers between a cljs frontend and a clj backend?

grav11:01:46

Currently we use bignumber.js on the frontend for some calculations, and I need to pass those in some format to the backend

chedgren11:01:17

Strings are not a bad option, unfortunately

chedgren11:01:43

oh! its clj all the way.. nvm

martinklepsch11:01:45

@grav: my reflex answer would be suggesting transit?

jaen11:01:45

@grav: use transit and add handlers for bignum that return bignumber.js objects?

jaen11:01:54

Dang, a second too late.

grav11:01:44

we’re using transit, but I don’t know how to make it work

grav11:01:58

@jaen handlers might be the magic word I need to find some documentation

jaen11:01:35

@grav: what do you talk to the backend with?

jaen11:01:45

cljs-ajax, cljs-http, sente, something else?

grav11:01:03

i believe it’s cljs-ajax

grav11:01:06

two secs

grav11:01:37

yes, cljs-ajax it is

grav11:01:49

so I need to implement read and write handlers, I guess?

jaen11:01:36

Yup, let me dig some example

jaen11:01:11

Then you just need to wire it up with cljs-ajax and whatever you use on the backend.

jaen11:01:21

I've used sente here, so that will not help you, probably

jaen11:01:40

But from another project, this looks a bit like this:

(def my-default-formats
 [ajax/json-response-format
  ajax/edn-response-format
  #(ajax/transit-response-format {:handlers transit-utils/transit-read-handlers})
  ["text/plain" ajax/raw-response-format]
  ["text/html" ajax/raw-response-format]
  ajax/raw-response-format])

(defn api-call [method uri opts]
 (let [; ...
       format                {:format (ajax/transit-request-format {:handlers transit-utils/transit-write-handlers})
                              :response-format (ajax/detect-response-format {:response-format my-default-formats})}
       api-opts              (merge opts format)]
   (match method
          :get  (ajax/GET  uri api-opts)
          :post (ajax/POST uri api-opts))))

jaen11:01:57

You will probably be able to find exact documentation for that in the cljs-ajax repo.

maleghast11:01:24

OK, I just started playing with cljs and Om this afternoon for the first time, so please bear with me, but can anyone tell me why, in the tutorial I am following, that deleting from the DOM uses a core.async channel, but adding does not..?

maleghast11:01:52

i.e. Is there a good reason to NOT use a channel when adding something to the DOM?

jaen11:01:28

om.prev or om.next?

maleghast11:01:33

(I thought it was om.now..?)

jaen11:01:15

Maybe, I don't use om, so I don't know how majority of om users call it. I just called it like that, because previous is a direct antonym of next.

jaen11:01:27

Anyway, if you're talking about the Quick Start tutorial

jaen11:01:12

My take on it is because triggering a deletion is done in an another component, but triggering an addition is done in the same component.

jaen11:01:30

So you somehow have to notify this component about the deletion, hence the channel for deletions.

jaen11:01:57

Were the addition form a separate component, it would probably use a channel as well.

jaen11:01:08

Though I can't know what the intention of the maintainer was.

jaen11:01:40

Also, I think there's an #C06DT2YSY channel, people there might have some more in-depth insight, as they are day-to-day users of om.

maleghast11:01:51

Thanks @jaen that’s really helpful simple_smile

jaen11:01:53

Sure thing; hopefully it's a good explanation ;' )

cl0jurian12:01:12

hi guys anyone using a an angular 2 with cljs? I have searched for a good wrapper found and used this https://github.com/dribnet/acute

grav13:01:32

@jaen thanks for the pointers, I’ll look into it

ashercoren13:01:03

I have a problem with ClojureScript Core-Async . This only happens in ClojureScript and not in Clojure. I have the following code:

(defn cc [x]
  (go 
    (println "cc: " x)
    x))

(defn foo [x]
  (go
    (when (and (= :ok (<! (cc x)))
               (= :ok (<! (cc :ok))))
       (print "after and"))))

(foo 1)
(foo :ok)
When calling (foo :ok), the result is as expected - the function cc is called twice, and the console shows cc: :ok cc: :ok after and. But, when running (foo 1), the function cc is also run twice and the console shows cc: 1 cc: :ok. So, even though the first condition isn't fullfilled, the second one is still checked!

bojanx10013:01:48

Hi, question about figwheel: Can you track some .edn file change (map of string translations) and then reload .cljs file (one that compiles that map) that depend on the .edn file? Thanks.

dnolen15:01:39

@ashercoren: it might just be a core.async bug in the ClojureScript part of the library

euandreh15:01:41

@martinklepsch: Yeah, I noticed that people used mainly React.

euandreh15:01:47

@jaen: I’m stuck with Angular, actually. I’m working in a team that’s using Ionic, and they have already considered React.

jaen15:01:01

@euandreh: I see; why not stick with typescript or Dart which are officially supported then?

jaen15:01:17

They don't seem to be that bad. And even have types!

euandreh15:01:31

No macros =/

jaen15:01:29

Yeah, I know it's probably not the answer you were expecting, but I didn't really see anything newer than gyr around

jaen15:01:03

Most people just gulped the React wrappers as if there were no tomorrow.

jaen15:01:27

Though, I can understand that. The frameworkiness of Angular is probably off-putting when you use a language that prefers libraries.

euandreh15:01:46

Thanks, anyway =]

euandreh15:01:37

Yep, and the “framewokiness” of Angular 2 is way better than Angular 1

jaen15:01:48

Yeah, a friend has to write something in it and says something to the effect "feels better than Angular 1, though still prefer React".

jaen15:01:59

I like how they officially support typescript and Dart though.

euandreh15:01:35

Sure, TypeScript in way more idiomatic that ES6

jaen15:01:47

If you want you could try using gyr/purnam, but I'm afraid it'll just be a varying degree of painful, so it'll probably be best, bit the bullet and decide on either of TypeScript or Dart.

jaen15:01:21

Idiomatic is one thing, having optional typesystem is always cool. Though bivariant genercis are a bit surprising at first.

euandreh15:01:54

Yep, optional typing is one of the best features.

ashercoren15:01:03

@dnolen: : That's also what I thought. Should I open a bug somewhere?

dnolen16:01:09

@ashercoren: bugs are filed in JIRA

schrepfler23:01:35

are there any isomorphic clojurescript apps which are js on the frontend but actually closure on the backend (in essence run everything which has a jvm implementation natively on the jvm and run the rest embedded in a js (nashorn?) wrapper with some transparent interop between the two