This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
cljs.core/declare seems to not work in the repl. Is this a known bug or perhaps somethings wrong with my environment?
I found this old jira report http://dev.clojure.org/jira/browse/CLJS-445 but it’s closed as “Completed"
Is there something similiar to clojure.lang.PersistentQueue
for cljs? I want to "rotate" a list efficiently, like using pop
and conj
on a queue
@jonas: FWIW, declare
actually does affect the analysis metadata at the REPL. The problem is that the compiler doesn’t emit valid JavaScript (it is really a NOOP from that perspective).
declare
and def
without an init form could probably be made to work at the REPL; we already have at least one thing in master that works differently to cater to the REPL: http://dev.clojure.org/jira/browse/CLJS-934
@wildermuthn: This article might interest you http://dev.solita.fi/2014/03/18/pimp-my-repl.html
@wildermuthn: Specifically the “Keeping utilities at hand with Vinyasa” section. It sounds like it’s implemented similarly to your idea of tossing things into .core though
@dnolen: I noticed that numbers and ‘default’ yields sequential hash code values. I’ve got a map w/ dom nodes as keys & i’m wondering if a better distribution of hash values would perform better
Anyone have any experience integrating Google maps into an Om project? I am getting alot of “Uncaught TypeError: Cannot read property 'x' of undefined” errors.
This is what my code looks like: (defcomponent page [_ owner] (render [_] (dom/div {:class "maps_page" :ref "map-canvas" :style {:width "100%" :height "100%"}})) (did-mount [_] (let [map-div (om/get-node owner "map-canvas")] (google.maps.Map. (clj->js map-div)))))
You shouldn't need to call clj->js for that (get-node should return the native DOM node).
I would step back and make sure you're getting the element and can manipulate it before bringing the google maps stuff into it
clj->js is a helper function that, at runtime, recursively converts a cljs map to a js object
I am pretty sure that isn’t needed. I am using that syntax, without the #js in other components without any problems
if it does work, 1) i’d be surprised that dnolen changed that and 2) it’s definitely slower
look at all the examples: https://github.com/omcljs/om/wiki/Intermediate-Tutorial
and since #js is shallow, you also need it on the style map: #js {:style #js {:color “red”}}
Can you try adding a logging statement to did-mount to verify it’s running correctly?
(.log js/console “message”)
, etc.
What does google.maps.Map eval to in the browser’s console?
i don’t think you can’t mix advanced & not advanced, if the google maps stuff is already advanced compiled
well I am in figwheel. I don’t think that even works with :advanced and my profile is set up for :none, but it is looking wierd
are you sure that externs file correctly? what if you give it an invalid path, do you get an error?
bbloom: is right, om.dom
takes js objects while om-tools.dom
takes whatever you give it.
I was just slightly put off by the fact that it was not completely up to date. It is at v3.18 for google maps, and the official current version is 3.20. And since it doesn’t actually include the js library, just the externs, it might cause trouble
@casperc: it does include the library, just not in the source, read the build.boot
file.
@casperc: if you want the latest one, packaging it is trivial, usually changing the version number somewhere in build.boot
@bensu: compare to https://github.com/miner/herbert
@bbloom: how come I've never seen this before? Is there a way of using it with defn
or one just writes {:pre (conforms ...)}
@bensu: you haven’t seen it before b/c there’s no venture back startup attempting to advertise themselves via it
anyway, this approach is seriously preferable b/c it doesn’t rely on an evaluator to build a schema object. instead it relies on an evaluator to interpret data… which means you can parse and manipulate schemas directly w/o special library support
@bbloom: not at all. but give me a week whenever I talk to you 5 minutes I spend a week googling stuff.
let’s imagine a library of “schema combinators” which have the function signature x => valid?
you can take normal predicates like string? and use them as validators, or you can build up more complex ones
the fundamental difference in implementation is that core.typed operates only as a compile-time linter
@bensu: that both function is now a predicate factory, and many of those things will form a “combinator library"
@bbloom: I see where your are going, that is why the error messages are so bad, fn
closures are opaque.
if you do the list ‘both thing, you can now do (defmulti validate? (fn [schema subject] (first schema)))
@bbloom @bensu: I’ve not used the schema library much (or any combinator library really). Can you give an example of a bad error message?
schema goes out of it’s way to recover the input syntax to provide sensible error messages
if it didn’t do that work, it would just fail w/ like a memory address of the function
@bbloom: Also, was that an arbitrary design decision, or were they limited by how they wanted the library to behave?
there’s nothing you can do w/ functional combinators that you can’t do better another way
Right, so they don’t know who gave them the function, just that it failed. The call stack should have some relevant info though, right?
@potetm: if you use (s/either SomeType AlmostThatType TheValidatedType)
and it fails on AnotherThing
the message explodes with descriptions of all the types, and nothing pointing to which of types in the either
caused the failure.
(defmethod validate ‘both [[_ a b :as schema] subject] (when-not (and (validate a subject) (validate b subject)) (throw (ex-data “Validation failed” {:schema schema :subject subject}))))
if schema was a function or other opaque custom object, i’d have to do extra work to recover the syntax to report it in the error
Right. So, point being, transmit the data, parse the data. Don’t build some arbitrary, opaque verification.
@bensu about the either
operator: https://github.com/Prismatic/schema/pull/134
@bbloom: cool, useful rant. I just watched @ztellman talk on macros (very good btw) so I'm ready to write some macros. I have ~3kLOC using prismatic/schema
it would cool to redefine the s/defn
macro to use herbert
schemas and make a smooth transition.
Is there a way to have :pre and :post on functions enabled on a dev build and disabled on a production build?
@bbloom: one other thing I forgot to ask you last time: after reading that cljs-vdom
was not interested in providing cross browser compatibility I went and read React's synthetic event layer. It is not the greatest thing, but it doesn't change much. Do you think it would be a lot of work to extract it and apply it over cljs-vdom
?
i just pushed a change to cljs-vdom to enable reverse lookup (node -> vdom id), which is necessary for event routing. still trying to figure out how to use it
react.js also does some voodoo to make events faster in ways that only really seems to matter for mobile (eg fewer allocations) - i’m not interested in mobile
@bbloom: agreed, I've been in that hammock for months now without good ideas. What I do know is that any event system (or whatever replaces it) could use the browser compatibility layer that those huge projects provide.
so i expect to achieve browser compatibility via a component library, not via low-level normalization & polyfill
I can see that, but what happens when you need to offer an escape latch for that person that needs the onclick
, do they get the browsers onclick
?