Fork me on GitHub
#clojurescript
<
2015-12-17
>
anisoptera00:12:07

"stuck with lein" ... whereas I want to use lein, but ambly is so nice

anisoptera00:12:22

maybe figwheel is better. I'll experiment sometime tonight

anisoptera00:12:21

i feel like it would be better in general if we could all agree on one build tool instead of reimplementing it several other ways, especially since lein is a fantastic build tool

darwin00:12:59

My apologies, I didn’t want to hurt anyone’s feelings. Lein is a solid tool, it has its quirks and learning curve. Now I’m pretty comfortable with it after mastering checkouts, profiles and cljs-build tricks. But all the cool kids are now using boot...

anisoptera00:12:31

haha, I'm more railing against the general CADT-ness being imported from the JS community here

anisoptera00:12:40

no feelings hurt afaict simple_smile

anisoptera00:12:22

I just don't understand the reasoning behind reimplementing all of Clojure's tooling instead of just tweaking it. it makes it a very difficult transition to go from vanilla Clojure to cljs

darwin00:12:10

and now imagine transition from javascript to cljs (without prior java ecosystem knowledge) simple_smile

darwin00:12:30

that was my path, not easy

darwin00:12:53

and now I’m slowly discovering clojure

anisoptera00:12:00

I mean, you still have to learn a bunch of new things, right? Wouldn't it be better if those new things you learned were a standard set of tools for all Clojure dialects?

darwin00:12:54

in a perfect world, yes. but in imperfect world, we need some competition and messy situations forcing us to evolve simple_smile

anisoptera00:12:13

sure. I certainly don't want to go the route of "don't ever try to make anything better". But I think that of all the things to try and rewrite/improve on, lein is far from the lowest hanging fruit. It's really good. It's probably one of the best build tools in any language, because it's built on maven, which is also one of the best build tools in any language.

anisoptera00:12:34

I don't even like Java, and I almost wish I used it so I could have maven

anisoptera00:12:36

that said, cljs is still in the rapid development phase so of course lots of people will take lots of different directions. It's just frustrating to get into if you aren't paying constant attention

anisoptera00:12:20

there are what, three? four? different ways to get cljs running on iOS now

anisoptera00:12:06

at least we mostly agree that React is the way to go, I guess simple_smile

jaredly01:12:52

@anisoptera: as far as “best build tools in any language”, I’m not sure what your metrics are, but in my experience, it has a lot of quirks, and coming from javascript, I wish for something simpler / more approachable

anisoptera01:12:22

I guess I don't see how it could really get much simpler than lein

jaredly01:12:33

for clojure, sure

anisoptera01:12:35

like, stick your deps in a vector, run a command and away you go

anisoptera01:12:16

well this is my point. shouldn't the focus be on improving lein's cljs workflow, instead of just deciding to write a new build tool, with hookers and blackjack?

anisoptera01:12:20

now we have a bunch of people working on the same problem, but they're split between two different tools; and to a newcomer, we present a less unified front. what got me started in clojure was the fact that the "getting started" story was very clear

anisoptera01:12:31

download lein, type this command, and away you go

anisoptera01:12:17

i'm not against trying to do it better in principle (or i'd be writing asm or C) but I just don't think it's a good use of resources to reinvent wheels because this time we'll get it 20% rounder

anisoptera01:12:01

i haven't had any problems with lein on cljs either, which is why i'm sort of confused as to the rationale behind creating a separate, cljs-only tool

donmullen01:12:47

@ananthmv: very much disagree - boot is a far better build tool especially for clojurescript. Sometimes you have to take the time to think through the pain points and get to a better place. The #C053K90BR team has done that - in spades.

donmullen01:12:06

Just ask folks like @jaen - and many others - who switched to boot and would never go back simple_smile.

anisoptera01:12:32

so what's it offer over lein? like, is there a comparison somewhere?

anisoptera01:12:56

maybe I'm experiencing pain and I don't even realize it, I am open to that concept simple_smile

johannjohann01:12:05

theres a nice blogpost

alandipert01:12:50

speaking of, we pushed v2.5 today and i wrote a little about it - http://adzerk.com/blog/2015/12/boot-2.5-released/ we're in #C053K90BR if you have questions or problems

johannjohann01:12:53

boot is pretty cool. the cljs tooling is a little more composable than the figwheel experience, which has its perks

anisoptera01:12:12

ok, I'm going to swallow my initial reaction at scripted builds and see if maybe this time someone did it in a way which doesn't lead to madness

donmullen01:12:06

@anildigital: understood — give a solid look — I think you will be pleased with what is there. LISP can do it simple_smile

alandipert01:12:09

@anisoptera: boot is about programming (creating) instead of configuring (filling out forms). if you like to program, i bet you'll like boot 😺

kingoftheknoll03:12:12

So this is using the ‘controller as’ syntax that’s why you’re not seeing the $scope. I’m testing the digest aspect now but that doesn’t appear to be it. Angular runs it’s digest loop regardless and if you mutate a value on the controller or $scope it’ll repaint

kingoftheknoll03:12:33

only thing I can reason about is that aset only works on vars in the global namespace

kingoftheknoll03:12:56

because if I pass window.i = {src: 0}

johannjohann03:12:46

maybe try (set! (.-src js-var) %4)

kingoftheknoll03:12:15

I don’t think it’s a js thing because the technique of passing a object and mutating it’s prop is commonplace. I’m actually doing that for it’s current implementation using Baobab.js which is a copy of Om cursors sortof

kingoftheknoll03:12:55

I have a abstraction layer that takes an object and updates it on state change.

kingoftheknoll04:12:07

very similar to add-watch

johannjohann04:12:40

do you have a button or something that you are tapping that swaps the atom? wanna get a good feel for what yr setup is rn

kingoftheknoll04:12:56

ah figured it out

kingoftheknoll04:12:14

it was the $scope.$digest

johannjohann04:12:16

cool what was the knot

kingoftheknoll04:12:44

way I was testing it looks like it was doing it on the same frame… maybe

johannjohann04:12:06

yeah when i did something like this i had my watcher take a cb that included the scope digest stuff

kingoftheknoll04:12:14

I think this would’ve been solved if I added a watcher that kicked off the digest on any change in the atom

kingoftheknoll04:12:02

lol but I’m hacking together the angular code in a string that’s I’m serving from a jetty server running figwheel

kingoftheknoll04:12:08

much harder to write js that way

kingoftheknoll04:12:34

so I was trynig to proof of concept with as little angular code as possible

johannjohann04:12:08

glad you've arrived at what you were looking for simple_smile

kingoftheknoll04:12:55

thanks man I really appreciate you taking the time to hack it out with me!

johannjohann04:12:16

np trying to build up computer karma for my next debug session 😄

kingoftheknoll04:12:03

sending good vibes your way man

johannjohann04:12:03

thanks. best of luck! heading out for the nite. be sure to update us with your progress!

krchia06:12:55

can someone help me with using pixi with cljs?

krchia06:12:32

i don’t get an error but the image i uploaded doesn’t show up

krchia07:12:32

i really don’t get an error. i’m using https://github.com/alexkehayias/chocolatier this as a guide

krchia07:12:53

if i clone into his repo he can load the images and but my project cant

krchia07:12:23

ok.. i got it 😃

hugobessaa07:12:47

Always great to watch this talk again https://m.youtube.com/watch?v=LNtQPSUi1iQ Love how they show pros and cons

danielgrosse08:12:36

I would like to merge a map into a existing map, using assoc-in. Is this possible?

jaen09:12:39

merge-with?

danielgrosse09:12:45

I realized it with let So i get the old data, then merge it with the new and then assoc-in to the database

nbdam09:12:21

Dirac is very cool +1

hugobessaa09:12:26

@danielgrosse: is this map nested inside the structure you are assoc-ing into?

danielgrosse09:12:21

{:available-sessions {12345 {:id 12355}
}}
merge 12345 with
{:name „Name“
:add-info1 „foo“ } 
actually I use
(fn [db [sess-id tour-info]]
    (let [curr-data (get-in db [:available-sessions sess-id])
          merged-data (merge curr-data tour-info)]
    (assoc-in db [:available-sessions sess-id] merged-data)))
  )

jaen09:12:39

@darwin: yeah, I can understand not wanting to give up hot reloading, but boot has that as well in boot-reload. That said, I haven't used figwheel extensively (a year ago it was hard to get all those lein-cljsbuilds, austins, weasels, piggybacks and figwheels to cooperate) so it might have advantages over boot's reloading. I'll probably take a look at it when I have some time and ask around on #C053K90BR if what you've done for figwheel is easily replicated with boot-cljs-repl and boot-reload, since those low-level details you meantion feel pretty specific, so it might not be straightforward.

jaen09:12:06

@anisoptera: out of curiosity what is CADT-ness? Is it a bit like NIH?

hugobessaa09:12:53

You could go with

(update-in db [:available-sessions sess-id] merge tour-info)

jaen10:12:00

@nha: hah, I suppose that makes sense. Javascript certainly has it's what's-the-flavour-of-the-week phase. LISPs had too. Hopefully the Java part of Clojure's heritage will weather that down a bit.

nha10:12:11

@jaen: I did not know that for lisps, but I've experienced it first hand for Node/Js. The Java "Give me one good reason to switch" could help, although I can't help but wonder why we have so many webserver libraries now

jaen10:12:00

I'm not old enough to have experienced that first-hand, but LISP seems to have this notoriety of being language of programmers that are on one hand brilliant, on the other - sick with NIH and short attention span. Something as described here - http://www.shenlanguage.org/lambdassociates/htdocs/blog/bipolar.htm

krchia10:12:11

how does one translate this into cljs?

krchia10:12:18

$('canvas').mousedown(function (e) { … }

jaen10:12:43

(gevents/listen js/window EventType.MOUSEDOWN
  (fn [e] ...))
Where gevents is goog.events, and EventType is goog.events.EventType.

krchia10:12:15

yes, that works for me 😃 thanks

nha10:12:15

@jaen: interesting. I kinda recognize myself into this ^^

nha10:12:46

Also, funny that this is on the shen website.

danbunea11:12:54

In Cljs we want to make all the operations that will occur on out app-state atom in a single function. For this we said we'll write the code like: '(defn change-title [title] (try (swap! app-state #(-> % (assoc :text title) ((fn [state] update state )) (assoc :text title) (assoc :text title) (catch js/Object e (swap! errors conj e))))'

danbunea11:12:24

have all the operations like in a chaing using ->

danbunea11:12:38

it is great, until I have to use ajax calls

danbunea11:12:44

and channels

danbunea11:12:50

could I do something like: '(defn change-title [title] (try (swap! app-state #(-> % (assoc :text title) ((fn [state] (let [data (<! ....) (assoc state :data data))) )) (assoc :text title) (assoc :text title) (catch js/Object e (swap! errors conj e))))'

danbunea11:12:13

act someway as if the code would be sync?

danbunea11:12:36

without an intermediary swap in a go block?

danbunea11:12:55

in javascript I'd use promises

danbunea11:12:13

.then(assoc ) .the(GET.. .then(assoc

eugekev11:12:34

@jaen: great read. Thanks for sharing.

jaen11:12:42

Yeah, it's pretty interesting to see what kind of programmer the power and malleability of LISP appeals to and what are the downsides to this. Well, at least from a certain viewpoint. Hopefully Clojure avoids that well enough.

dnolen13:12:44

@jaen I don’t think that post says as much about LISP in general as it does about the (Common) LISP community post AI-winter

pvinis13:12:30

is om using actual react, or is it doing stuff the way react does it? also, my real question, can i use react thingies like react-three etc with om?

dnolen13:12:33

it definitely does a poor job of painting prior 30 years of LISP development, and largely ignores the Scheme narrative (and eventually Racket)

dnolen13:12:04

@pvinis there’s an #C06DT2YSY channel

dnolen13:12:39

@pvinis and yes Om actually uses React and you can use 3rd party components

pvinis13:12:17

op, forgot about the channel. cool

danbunea13:12:10

In javascript, you could actually use Ramda (http://www.ramdajs.com) to compose functions and ajax calls in a promise (http://ramdajs.com/0.18.0/docs/#composeP ). How can I do something similar?

danbunea13:12:23

var func = R.composeP(dosomething1, $.ajax(), dosomethingelse)

dnolen13:12:25

@danbunea: in ClojureScript core.async is probably the most popular way to deal with asynchrony

dnolen13:12:48

you can of course use JS promises in ClojureScript but it’s not very popular far as I can tell.

danbunea13:12:03

I'm trying to use channels, howver from what I see a go block returns the channel, not the value read from it (go (<! (somechannel))

dnolen13:12:04

@danbunea: conceptually how is that different from a returning a promise and not a value (since async)?

dnolen13:12:29

only inside of go blocks is the illusion of synchrony maintained

dnolen13:12:54

this is exactly the same conceptually as ES2015 function* + yield

danbunea13:12:34

basically I want to swith my entire app-state in a single function call

danbunea13:12:43

(swap! app-state func)

danbunea13:12:19

and I want to compose that func in a way that allows async code (promises, channels anything that could work)

danbunea13:12:41

in js I'd do var func = R.composeP(dosomething1, $.ajax(), dosomethingelse)

dnolen13:12:27

but func returns a promise

dnolen13:12:44

and my point is what you’re doing in JS isn’t going to be any different in the big picture from ClojureScript

danbunea13:12:07

yes, you're right

danbunea13:12:23

I'm just testing posibilities

dnolen13:12:59

in core.async instead of bothering with all these combinators - just write the code

danbunea13:12:31

someone said to me: (go (doto app-state (swap! assoc :context "loading") (swap! assoc :data (<! (async-get ""))) (swap! assoc :context "edit") (render)))

danbunea13:12:48

but I find this approach bad, because if I have an error in my get

dnolen13:12:07

@danbunea: go blocks support try/catch

danbunea13:12:07

my app-state will be in an incosistent state (:context loading)

dnolen13:12:28

and that’s not how I would write that anyway

danbunea13:12:07

I'n new to cljs so thank you for your pacience

danbunea13:12:36

I'm just trying to make my swaps of the app-state from one to another, completely consitent

danbunea13:12:55

like all operations of nothing , transactional if you'd like to call them that way

danbunea13:12:24

all operations OR nothing

danbunea13:12:27

sorry, type

dnolen13:12:38

@danbunea: unlike promises there’s no standard way to do error handling

dnolen13:12:50

but it’s more or less trivial to do it however you want

danbunea13:12:41

Thank you,I'll read it now

martinklepsch13:12:02

Is there a way in JS to see where the current script has been loaded from?

dnolen13:12:56

@martinklepsch: not from the script no

martinklepsch14:12:38

maybe using document.currentScript and then looking at the src attribute will do it..

dnolen14:12:54

@martinklepsch: doesn’t work at all in IE so as long as you are OK with that.

martinklepsch14:12:36

@dnolen: it's in a devtools context so I guess it's an acceptable tradeoff

magomimmo14:12:03

hi all, I just published a new tutorial of the modern-cljs series (https://github.com/magomimmo/modern-cljs) which now uses boot and related community based task instead of leiningen/cljsbuild. This tutorial try to build a TDD environment with a CLJ and CLJS REPLs as well. It uses, with some shortcoming, both boot-test and boot-cljs-test tasks on portable .cljc files/namespaces. Hopefully someone will find it useful. Here is the link: (https://github.com/magomimmo/modern-cljs/blob/master/doc/second-edition/tutorial-16.md)

jaen14:12:21

Looks quite nice. Though any particular reason you're using src/clj / src/cljs / src/cljc instead of something more descriptive like src/backend / src/frontend / src/common?

juhoteperi14:12:19

I think it's better to use per filetype dirs, the file handling depends on the type and not that much about the usecase

juhoteperi14:12:42

clj and cljc files should be included in build artifact, while cljs files don't need to be included in the build artifact

juhoteperi14:12:38

And you can still use descriptive names for namespaces

jaen14:12:08

Okay, that is a point, I suppose.

jaen14:12:45

Though what about Clojurescript macros - where you would put it and why?

alandipert14:12:29

for me the distinction hinges on whether app or library. for libraries i use clj/cljs, for applications i use frontend/backend

juhoteperi14:12:13

I use src/clj and src/cljs for apps too, and then I use backend.* and frontend.* for namespaces

jaen14:12:51

@juhoteperi: I see; but what about the Cljs macros then? do you put them in src/clj because they are Clojure files or in src/cljs since they are not needed in the resulting artifact?

juhoteperi14:12:30

@jaen: Humm, I checked couple of projects and couldn't find any macros 😄 Both should work, but if it's purely cljs macro and not useful for Clojure, I would put it in src/cljs.

jaen14:12:37

I guess that's sensible. What's the reasoning behind not putting those files in the resulting artifact?

jaen14:12:43

I mean, can sound like a dumb question'

jaen14:12:48

But genuinely curious.

jaen14:12:10

Just the filesize concerns or something else?

juhoteperi14:12:50

Yeah, if they are not needed it will save few KBs, probably doesn't matter a lot

magomimmo14:12:29

@jaen: what if the backend is on cljs/nodejs? I’d probably make a different classification. At the moment I’m happy with src/clj src/cljc and src/cljs

jaen14:12:58

@magomimmo: then nothing changes, backend still goes into src/backend and frontend into src/frontend, I think. But I kind of understand the point of view deraen explained there.

jaen15:12:45

I've used to use the same directories as you, but at some point I realised that descriptive names just made more sense to me. src/cljs tells me litte, src/frontend somewhat more; especially considering the fact I then have frontend / backend / common in my namespace, so I know what it pertains to.

jaen15:12:08

With src/cljs you don't get that (unless you do src/cljs/frontend of course)

magomimmo15:12:03

@jaen: i don’t care to much. I like to move the gears from one side to the other and viceversa (i.e. isomorphic application)

jaen15:12:45

Then I would those parts in common. But I guess to each his own.

juhoteperi15:12:55

@jaen: So in your src/backend and src/frontend case, is src the source-path and backend and frontend are part of namespace?

juhoteperi15:12:32

Right. So I use the same namespaces but I have separated the filetypes to separate source-paths.

jaen15:12:53

Yeah, I noticed. And I agree if you want to exclude certain files from the resulting jar that might make sense. I just never felt a need to.

jaen15:12:00

But then again - I've never made a library.

magomimmo15:12:03

@jaen: when I say “move” I mean movable parts, to be more precise, at runtime

jaen15:12:50

Hmm, I'm not sure I understand that. How would that work?

magomimmo15:12:18

@jaen: it’s very hard to explain it here, even because the idea is still in my mind. I want to be able to move a module/service or whatever want you call it from one side to the others and viceversa…in a kind of p2p architecture

sashton15:12:54

has anyone tried sending a prismatic schema to cljs via transit? I'm trying the following:

(ajax.core/GET "/api/schema"
  {:response-format
   (ajax.core/transit-reponse-format
       {:raw false
       :reader (transit/reader :json-verbose
                               {:handlers outpace.schema-transit/read-handlers})}
But I get No protocol method IEmptyableCollection.-empty defined for type [object Object]

jaen15:12:41

@magomimmo: oh, that seems to be a quite interesting idea.

magomimmo15:12:16

@jaen: but it needs legs to walk 😞

sashton15:12:44

I'm trying to follow along here: https://github.com/outpace/schema-transit and here: https://github.com/JulianBirch/cljs-ajax/issues/108 Not quite sure what I'm missing

sashton15:12:25

hmm, got it working after all. in this case we seem to need :raw true.

wilkerlucio16:12:10

do you know how can I detect a plain js object in clojurescript? in JS it would be like typeof x == 'object'

wilkerlucio16:12:06

found the answer looking at js->clj source: (identical? (type x) js/Object)

vipaca16:12:23

Hi all, I have something that is confusing me. I have piece of clojurescript that uses recursion to traverse a set of states stored datascript. At the tail I would like to reset an atom at each state and pause for a moment playing back the states from beginngin to current. This works with prn as expected I see each state printed to console, however the atom is only getting reset once it seems. Any thoughts what might be going on?

frank16:12:42

Does anyone know how to connect to the nodejs repl started by the script/repl.clj script in the Mies template?

frank16:12:21

Also, is it possible to get that repl to run my -main function when it starts?

magomimmo16:12:57

@juhoteperi: you were right about :dir and :resource-root. As I have time I’ll fix the tutorials

ddellacosta20:12:02

vipaca if I had to guess I’d say it’s getting reset vs. swap’ing with something that is accumulating the data you want

ddellacosta20:12:06

but I’d have to see it to know for sure

ddellacosta20:12:24

oh, but you’re using datascript, I don’t know much about that, sorry

vipaca20:12:48

I pretty sure its not the atom functionality but rather om framework.

vipaca20:12:52

I'm expecting the om component to trigger event based on state change of the atom, but this assumes that the event handler changing state has completed and in fact it has not.

vipaca20:12:01

Also, I was able to prn the reset! and see atom state changes when no rerender was occurring in app.

sdegutis22:12:01

Is it possible to use ClojureScript with advanced-optimization enabled inside a Clojure process without actually touching the real filesystem for any of the compilation, and end up with a single string representing the entire JavaScript program after advanced compilation?

dnolen22:12:08

@sdegutis: there’s no easy way to do that at the moment, there’s a ticket about it though

sdegutis23:12:14

@dnolen: Thanks for the quick response.