Fork me on GitHub
#clojurescript
<
2015-11-05
>
dnolen00:11:42

@bhauman: trying to figure out integrate reconcilers into the existing devcards model

dnolen00:11:57

it seems you use React for the whole page so you control the root

dnolen00:11:22

this is not actually a big problem for Om Next, things are decoupled enough that a reconciler doesn’t really need a real root to work

dnolen00:11:34

but I’m struggling a bit with the custom card w/ state example

dnolen00:11:46

the init-state bit can I pass my own atom here instead of plain data?

dnolen00:11:11

@bhauman: and what is the state filter bit for (the second argument)?

bhauman00:11:11

@dnolen: where are you?

bhauman00:11:30

oh custom card with state

dnolen00:11:36

state-over-time-view in custom_cards.cljs example

dnolen00:11:08

basically want to sort this out so I can start writing real UI tests for Om Next

dnolen00:11:16

and then of course doc that so everyone else can too

bhauman01:11:57

@dnolen: if I am understanding you correctly (fn [state _] _ is the react element owner. but still not sure if that is what you want

bhauman01:11:11

@dnolen: happy to chat if that helps

dnolen01:11:27

ok I was just curious, yeah I don’t need the parent element

dnolen01:11:53

@bhauman: so every time the state changes this fn will be invoked?

dnolen01:11:58

and I should return a new component?

bhauman01:11:01

@dnolen the function will be invoked, you need to return a react element

dnolen01:11:25

ok so that’s actually a bit of problem

dnolen01:11:48

since Om Next is incremental it finds components to update

bhauman01:11:58

thats fine

dnolen01:11:00

and avoids starting at the root

bhauman01:11:19

so if you want to update internally thats no problem

dnolen01:11:51

so just don’t give state param?

bhauman01:11:18

just create a react container that works for your

bhauman01:11:29

@dnolen: actually the devcard option :watch-atom false should prevent rerenders of the function, verifying that right now

bhauman01:11:51

@dnolen: but I was thinking that I/we would be writing a defcard-next to handle the history and data display bits

dnolen01:11:42

yes that would be the next step

dnolen01:11:07

I just want to get basic rendering without a real root working first

dnolen01:11:41

@bhauman one thing I don’t understand is how to pass options

dnolen01:11:53

like :watch-atom false

dnolen01:11:27

is it just with the last map argument?

bhauman01:11:21

@dnolen yep with that last options map

bhauman01:11:47

:watch-atom false doesn't work

bhauman01:11:02

sorry, it's a bit complicated

dnolen01:11:32

but I can just return a component and be done with it right?

bhauman01:11:47

@dnolen: I'm anxious to help so if you have any problems or if you think making :watch-atom false work will help. Let me know

dnolen01:11:12

I just want the most basic thing to work

dnolen01:11:41

and then would like to explore how to reuse or reproduce the state functionality you already have

dnolen01:11:13

MIND BLOWN

dnolen01:11:30

the only changes that were required are in the second file

dnolen01:11:48

that’s all Om Next needed to be fully mocked into an existing React component tree

bhauman01:11:02

heck yeah!!

dnolen01:11:02

(defcard test-counters (om/mock-root counters-reconciler CountersApp))

dnolen01:11:12

that’s it

bhauman01:11:32

That's awesome!!

dnolen01:11:21

@bhauman: so yeah the only thing I would want is the ability to give you a history hook

dnolen01:11:31

but have that only get fired when history controls are used

dnolen01:11:35

re-render should never fire

dnolen01:11:26

OMFG this is going to save me so much time

dnolen01:11:21

@bhauman: so can devcards display an atom?

dnolen01:11:57

if I have my component as the first thing and try to return my atom as the second thing - that doesn’t work

bhauman01:11:11

@dnolen: to display an atom its (defcard my-atom atom-reference)

dnolen01:11:37

@bhauman: so there’s no standard mechanism for showing different card types in one card?

bhauman01:11:05

@dnolen: if I understand you correctly yes

bhauman01:11:45

but it's definitely been on my mind

bhauman01:11:05

you could of course compose via react

dnolen01:11:03

@bhauman: but you can’t nest cards right?

bhauman01:11:40

not obviously

dnolen01:11:36

got it, can live with that

bhauman01:11:53

React is awesome

mikethompson02:11:21

I'm looking for clarity about how to replace both in the new version of prismatic schema. (`both` is now deprecated) I want to assert that something is BOTH a sorted-map and that the key/value pairs of the sorted-map are of certain types. My previous, working schema was this (notice use of both):

(def schema  {:a  (s/both
                   PersistentTreeMap   ;; is a sorted-map (not just a map)
                   {TODO-ID TODO})     ;; in this map, each todo is keyed by its :id})
I'm trying to use constrained as a replacement for both, but I'm getting odd errors where I didn't previously:
(def schema  {:a  (s/constrained
                   PersistentTreeMap   ;; is a sorted-map (not just a map)
                   {TODO-ID TODO})     ;; in this map, each todo is keyed by its :id})
Is there anything wrong with my use of constrained? How should I do both? The offical docs: http://prismatic.github.io/schema/schema.core.html#var-both say to use conditional with a single condition which makes no sense to me. I have two conditions.

mikethompson02:11:26

Okay, the penny has dropped. (s/both a b) can be written as (s/condition a b) ... the a is checked as the predicate and b is checked as the body. Sneaky. So the final solution was: (s/condition #(instance? PersistentTreeMap %) {TODO-ID TODO})

lancefalcon11:11:12

How would I go about requiring something to be an instance of goog.date.UtcDateTime using Prismatic Schema?

martinklepsch11:11:02

Who’s compiling to Node.js? Please chime in here if you could be affected by a change in how the shim finds required files: http://dev.clojure.org/jira/browse/CLJS-1444

bensu11:11:59

@martinklepsch: For anybody interested in node.js the other ticket to look at (and patch to try) is http://dev.clojure.org/jira/browse/CLJS-1466

bensu11:11:37

@joelkuiper: @dnolen @richiardiandrea re: cycle.js After talking to the author (great guy!) about the library I got the impression that there is a lot of Not Invented Here in his work. There are some interesting ideas to extract (the specific RxJS + VDOM combination) but I wouldn't recommend it as it is, since it ignores the existing ecosystem and pretends to be a standalone final solution...

martinklepsch11:11:02

@bensu oh, nice. missed your last comment there.

dnolen13:11:15

@bensu ReactiveConf looked like an interesting event from afar.

mrchrisadams13:11:25

Hi there. I only have a basic understanding of clojurescript, but I’m fairly comfortable with javascript, and I was hoping I could ask for some pointers on what the equivalent cljs ought to look like, because I couldn’t see an example on this site: http://himera.herokuapp.com/synonym.html

mrchrisadams13:11:42

If I want to use an existing js library, like http://momentjs.com, and call moment().format('L'); what would the equivalent clojurescript look like? Something like ( js/moment ( js/format ‘L’) ) ?

colin.yates13:11:55

@mikethompson: That penny kept falling through to me as well - time to finally get rid of those pesky deprecation errors

delaguardo13:11:56

(.format (js/moment.) “L”)

mrchrisadams13:11:30

delaguardo: thanks! So as long as that js file is included on the page and loaded before clojurescript’s compiled javascript, I should be able to call it freely?

mrchrisadams13:11:29

cool - looking up now

dnolen13:11:00

@delaguardo: that should be (.format (js/moment) “L”) I think

acron13:11:02

mrchrisadams: simple_smile

delaguardo13:11:01

oh, my bad, but

moment()
is just alias for
new moment()
so i’m right too)

jstew13:11:29

Anyone here build an electron/clojurescript app? Seems like it should be fairly easy but just moving the proper js files into the electron shell. Are there any gotchas or tips to improve the workflow?

dnolen13:11:05

@jstew quite few people doing that far as I can tell

acidandy13:11:26

@dnolen can you elaborate on "fwiw I think core.async + React / Figwheel has shown that mutable observation is a big tradeoff" re:cycle.js? Or point to any resource explaining it? not quite following.

dnolen13:11:56

@acidandy: if you haven’t tried it then it will be difficult to understand

dnolen13:11:16

but mutable observation is a resource and must be managed if you need a life cycle

dnolen13:11:51

which you do in the React model esp. if you want stronger state management (time travel)

dnolen13:11:18

similar for hot code loading, you need to be very careful with observation

dnolen13:11:39

basically the observe operation is fundamentally stateful

acidandy13:11:00

Ah I see. Wasn't sure if it related to observers in that sense. Thanks!

dnolen13:11:57

the issue becomes clearer when you see that React events don’t need explicit addEventListener or explicit removeEventListener

dnolen13:11:06

this is a huge source of complexity that React just removes

dnolen13:11:38

you see the exact same problem found around traditional JS event handlers in RxJS observe/unobserve and in core.async loops that need a lifetime

jeremyraines15:11:07

not sure if this is more of a cider question vs clojurescript, but since I’m working in a cljs repl: can anyone give me a pointer on how to get my repl values to be pretty printed? I’m using whidbey for colorizing, but can they also be nicely broken into indented lines?

jeremyraines15:11:30

as opposed to, for example:

cljs.user> {:a {:b {:c :d} } }
{:a {:b {:c :d}}}

dnolen16:11:20

@bhauman: there’s not a version of devcards w/ React 0.14 is there?

asolovyov17:11:41

@bhauman: I'm trying to start with figwheel 0.5.0 and it complains that Could not locate clojurescript_build/auto__init.class or clojurescript_build/auto.clj on classpath. I looked through figwheel's project.clj and it's not there

asolovyov17:11:44

should it be there?

asolovyov17:11:26

oh, that's in my project, heh

asolovyov17:11:30

forgot to remove it simple_smile

tony.kay19:11:03

I'm starting figwheel sidecar from a clojure.main REPL. Everything works fine except (reload-config): java.lang.IllegalStateException: Can't change/establish root binding of: autobuild-env with set

tony.kay19:11:45

Am I missing something in my config/is there a known fix? My friend Google isn't helping

tony.kay19:11:08

Oh wait...figwheel didn't load the config, I did. Duh. Nvm.

pshk4r19:11:36

Can’t figure out how to generate URLs on cljs frontend using shared cljc file with silk routes pointing to backend clj handler functions.

pshk4r19:11:20

@domkm: ^ can you maybe help me again? simple_smile

domkm19:11:43

@pshk4r: Could you make a gist of what you have so far?

pshk4r20:11:47

@domkm: well, it’s pretty stupid now: https://gist.github.com/vitaly-pushkar/7e3715c8cc99388cbec6 of course cljs cannot ’see' clj handlers, but I actually don’t need it - what I want is to ask silk to give me urls for named routes, to not to hardcore urls on frontend and I can’t figure out how to make it possible

domkm20:11:48

@pshk4r: Have you tried silk/depart or silk/unmatch?

pshk4r20:11:41

@domkm I can’t run the app. I get adzerk.boot_cljs.util.proxy$clojure.lang.ExceptionInfo$ff19274a: No such namespace: me.front-office.handlers, could not locate me/front_office/handlers.cljs, me/front_office/handlers.cljc, or Closure namespace "me.front-office.handlers” - it tries to load my clj handlers as cljs which doesn’t exist, obviously

domkm20:11:51

@pshk4r: You'll need to use reader conditionals #?(:clj ... :cljs ...) to conditionally load code that is only compatible with one environment

domkm20:11:26

@pshk4r: Though that's a general issue, I don't yet really understand what you are trying to do with Silk

pshk4r20:11:51

@domkm, Let me try to rephrase it: I want to have one shared place between frontend (with cljs Reagent) and backend to define routes in. So whenever I need a link on frontend to point to pages which are not part of SPA (for example, /registration or /about ), I could use named routes instead of hardcoding these urls. I am pretty newbie here, maybe I get the whole thing wrong and trying to do something illogical.

domkm20:11:39

@pshk4r: Use reader conditionals to exclude serve stuff from CLJS routes

pshk4r20:11:00

@domkm: I will try, thank you a lot.

domkm20:11:08

sure thing