Fork me on GitHub
#clojurescript
<
2016-11-17
>
hwk05:11:41

I think the "problem" with "cursors" is that there's sorta only one place where you're supposed to be changing things.

hwk05:11:02

This works great if it's a single user application and there are no timers / no incoming data sources / no other updates.

hwk05:11:26

However, if you have timers / othter channels also sending updates to your app, something like reagent (with reactive atoms) may work better than Om (with a single data store + cursors)

hwk06:11:02

in cljs, is there a way to throw/catch arbitrary cljs data structure, rather than a (js/Error) ?

thheller08:11:08

@hwk (throw (ex-info msg {:thing "data"})) and get it via (catch :default e (something (ex-data e)))

andrewboltachev09:11:42

Hi. Is there 1-level version of clj->js?

danielstockton09:11:23

Is it possible to configure the figwheel server to catch-all routes?

andrewboltachev09:11:45

@danielcompton you probably need to setup custom ring handler

danielstockton09:11:47

wrong person, but ok, I'll look into this

danielstockton09:11:23

thanks for the pointer

danielstockton10:11:04

Trying this as a simple handler but doesn't work:

(defn handler [request]
  (io/resource "public/index.html"))

danielstockton10:11:27

Just get a 404 on any other route "Figwheel Server: Resource not found"

andrewboltachev10:11:48

ok, you might need "routes"

danielstockton10:11:56

Perhaps it isn't picking up the handler for some reason

andrewboltachev10:11:12

you (println ...) to figure this out

andrewboltachev10:11:21

or even (throw ...)

danielstockton10:11:25

Don't routes dispatch on something in the request? A simple handler shouldn't need routes.

andrewboltachev10:11:31

But am I getting right, you actually have added :figwheel {:ring-handler foo.core/handler} to project.clj?

andrewboltachev10:11:02

I mean :ring-handler to :figwheel section

danielstockton10:11:12

Oh, damn 🙂 Not exactly

danielstockton10:11:24

foor.core.handler...typo

andrewboltachev10:11:45

yes, and make sure there ain't like two :figwheel inclusions

andrewboltachev10:11:54

and everything's in place

danielstockton10:11:53

Got it working, thanks a lot

danielstockton10:11:26

Not with io/resource, but with

(ns dev
  (:require [ring.util.response :as resp]))

(defn handler [request]
  (resp/resource-response "index.html" {:root "public"}))

danielstockton10:11:36

Needs to be a proper ring response

hwk15:11:19

@thheller : thanks! (re ex-info, re-data, throwing arbitrary cljs data structures)

conan15:11:32

anybody know a good way of transpiling markdown into hiccup in cljs?

conan15:11:33

i can do it into html using something like yogthos/markdown-clj, but if the markdown is large then it's inefficient to keep rendering the html in react, it would be better to provide hiccup

borkdude16:11:57

With ag, how do I only search in ClojureScript files?

borkdude16:11:12

ag —clojure foo is too broad

bbss16:11:51

@kenny You asked about what's wrong with cursors, this blog expands on it: https://circleci.com/blog/why-we-use-om-and-why-were-excited-for-om-next/

borkdude16:11:24

ah, ag -G .clj\[sc\] foo is what I wanted then, thanks 🙂

borkdude16:11:04

for completeness:

alias ag-cljs='ag -G .clj\[sc\]'
alias ag-clojure='ag -G .cljc\?'

richiardiandrea17:11:56

@borkdude stealing that, thanks!

spacepluk17:11:06

hi, how do I reference js/Error at compile time?

jr17:11:25

for what reason?

jr17:11:44

js/Error should only be part of the compiled output

spacepluk17:11:38

I'm trying to catch an error in a macro that should work both for clj/cljs

dnolen17:11:31

I don’t think you want splicing-unquote here

spacepluk17:11:50

oops, that was me being desperate

spacepluk17:11:15

yields -> No such namespace: js

peeja17:11:55

@spacepluk You're using js/Error in :clj code

spacepluk17:11:05

it's a macro

peeja17:11:20

Oh, I see what you're trying to do

peeja17:11:36

You want 'js/Error

spacepluk17:11:47

I tried that as well, let me do it again

spacepluk17:11:26

nah, same 😞

spacepluk17:11:11

I chose a bad first macro

peeja17:11:54

Oh, I see the problem!

peeja17:11:00

err-sym shouldn't be a macro

peeja17:11:06

It should be a function, in clj

spacepluk17:11:45

hmm but then there's no &env

peeja17:11:58

Right, but &env is wrong here anyhow

peeja17:11:19

That's the clj environment, because you're calling a macro when the clj code of your other macro compiles

peeja17:11:39

You'll need to pass the &env from profile into err-sym

peeja17:11:50

(or just the :ns, if you like)

moxaj18:11:25

@spacepluk I myself use a little helper macro:

(defmacro cljs? []
  `(boolean (:ns ~'&env)))

spacepluk18:11:55

I'm confused

moxaj18:11:33

just macroexpand it and you'll understand

moxaj18:11:40

the ~' is to ensure that the literal &env symbol is embedded, not the namespace qualified

spacepluk18:11:45

but I don't completely understand why

moxaj18:11:13

it's the same as if you have typed (boolean (:ns &env))

spacepluk18:11:24

why do I need the function? :?

moxaj18:11:35

to save a few keystrokes 😄

spacepluk18:11:01

hehehe, but if I make it a macro it fails

moxaj18:11:02

you are missing an unquote though

moxaj18:11:55

Also, you can simply do

(catch (cljs?) `js/Error `Throwable ...)

moxaj18:11:37

oh wait I messed up

moxaj18:11:39

(catch ~(if (cljs?) `js/Error `Throwable) ...)

spacepluk18:11:32

wow this is mind bending hehehe

moxaj18:11:04

just wait until you get to double syntax quotes, that's where the real fun begins 🙂

spacepluk18:11:23

thanks a lot

borkdude18:11:37

Looking for a boot project example with working source maps

fellshard20:11:20

Re: the CircleCI Om Next article - the 'mutations' concept seems to lead in a direction resembling Redux's reducers, to the best of my knowledge. Is that accurate?

dnolen20:11:54

it’s based on Relay & Falcor - not Redux

fellshard20:11:38

No action-based dispatch, I guess that's a major difference. Will do more digging.

dnolen20:11:04

I mean Redux is not really innovating here that much

dnolen20:11:12

Flux had a variant of the command pattern - so does Redux

dnolen20:11:17

so does Om Next

dnolen20:11:34

but as far as direct inspiration - look at Relay & Falcor not Redux

jasonjckn23:11:09

anyone notice clojurescript compiler / figwheel slow down after they've been running it for a while?

jasonjckn23:11:51

the figwheel hotloading slows now and I need to kill the jvm and restart

johanatan23:11:35

what's the best/easiest way to import a NPM module for frontend/client-side use (and this NPM module has 4-5 other modules as dependencies). Neither it or its dependencies are currently provided by CLJSJS

johanatan23:11:41

[i haven't looked yet at the dependencies of those 4-5 other modules but if they each have a handful of dependencies, this could get painful fairly quickly]

johanatan23:11:24

The root module in question is: react-swipeable-views if anyone knows about or alternatives to this functionality in particular.

dnolen23:11:29

@jasonjckn haven’t encountered that myself