This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2015-07-03
Channels
- # admin-announcements (21)
- # beginners (13)
- # boot (215)
- # cider (36)
- # clojure (24)
- # clojure-berlin (7)
- # clojure-japan (59)
- # clojure-korea (2)
- # clojure-russia (5)
- # clojure-seattle (1)
- # clojure-uk (5)
- # clojurescript (119)
- # clojurex (4)
- # code-reviews (4)
- # cursive (8)
- # editors (3)
- # euroclojure (27)
- # ldnclj (15)
- # off-topic (57)
- # re-frame (1)
- # reagent (108)
- # yada (3)
@sooheon: thanks! yeah, the designers are looking for some alternative background images
I’ve got a question involving re-frame and typeahead. I’m trying to port the one from reagent-forms (https://github.com/reagent-project/reagent-forms/blob/master/src/reagent_forms/core.cljs#L192), and I’ve gotten as far as this: https://gist.github.com/sooheon/fbae36a1588504f6e594 Obviously it doesn’t work. Can anyone tell me where I’m going wrong? The repo (full of bad clojure) is here: https://github.com/sooheon/ku-live/tree/typeahead
@sooheon: I'm looking at the code ... can you be more specific about what doesn't work?
Ok, sorry to be vague this is my first time with cljs. Mainly, I’m not seeing any kind of popup of typeahead list when I type. Nor when completely remove the :hidden key val.
So does that mean you suspect this code: https://github.com/sooheon/ku-live/blob/typeahead/src/cljs/kulive/views.cljs#L68-L83
selected-index
in a reaction
but on line 79 you seem to be treating is as an atom (using reset!
)
So that's an issue, but perhaps not the immediate issue
This file is so big that github isn't showing it: https://github.com/sooheon/ku-live/blob/typeahead/src/cljs/kulive/db.cljs
(def db
{:courses {…}
:my-courses {}
:typeahead {:hidden? true
:mouse-on-list? false
:selected-index 0
:selections []
:value “”}})
So (get-in @typeahead-db [:input])
gives?
Oh, wait. That's in a threaded macro. Sorry
Still a problem?
@sooheon have you seem re-com ?
It looks to me that your "translation" of "reagent-forms" doesn't have anything fundamentally wrong. Just a few bugs.
I think your just going to have to knuckle down and put some debug statements in there and tuff it out.
We've found two things wrong ... there are probably others.
But, like I said, nothing fundamentally wrong.
Sure. Thanks for your input. So I take it the way I’ve set up dispatches/handlers in general you don’t see anything egregious about?
No, exactly.
Overall structure is fine
As soon as possible, I'd be sticking debug
middleare onto all your event handlers (not that I see any significant issues)
Other than that just println
Are you new to cljs ?
That's a steep learning curve
Well you've bitten off a bit for a first project
Yeah it really gave me many false epiphanies, and when it comes down to it I still know nothing
I'm streaming a new clojurescript + d3 + re-frame side project of mine over here: http://www.twitch.tv/escherize/ I have no idea what i'm doing re: streaming
@escherize: do you know about http://livecoding.tv? it was on reddit a couple days back, I only saw one cljs stream on there and it was pretty popular
@sooheon: I'm not sure what your goals are. But I think you'll have a more satisfying experience if you start with something that is working an slowly tweak it.
Are you just tinkering? Experiementing?
Or do you have something specific you have to get done?
Well I saw the crossclj search interface, and wanted to make something like that for my school course search
I wanted to have a functional search, save, timetable visualiser before next semester
Do you have to have it work across browsers, or can you mandate Chrome?
I guess chrome only wouldn’t be too bad, but I do live in s. korea where a ton of people use IE still
IE11 ?
yeah, I'm wondering if that is a good option for you
On the right, under Demo, choose "Dropdown with filtering"
Perhaps. Re-com does assume the availability of a modern browser (one with a flexbox implementation)
So if you feel good about mandating a modern browser, then re-com is probably a very useful platform
modern browser = IE11, firefox, Chrome, Safari
There is a lein template to get you going:
(although I note you were using boot)
You really should be able to use re-com with boot without the slightest problem
@escherize: there's a reagent-cookbook page on D3 and reagent: https://github.com/reagent-project/reagent-cookbook/blob/master/old-recipes/d3/src/d3/views/home_page.cljs
I think the trick is to:
- just put in a basic div
or svg
in the renderer
- do most of that D3 specific work in the did-mount
@sooheon: I've been using boot for a few things and agree with Mike that it should work for re-com. The folks on #C053K90BR have been very helpful as I've been going through the learning curve (I'm new to clojure and cljs as well).
Dear all, Here is a useful tip I picked up from @escherize ... When you are debugging a reagent view ... sometimes you want to see the value in an input (prop or reagent/atom) ...
The trick is to add something like this to the hiccup in your view ...
[:pre (with-out-str (pprint @some-atom))]
Up the top, you'll need to add a require to use pprint
like this ...
[cljs.pprint :refer [pprint]]
You can also just forget about using pprint
and do this:
[:pre (pr-str @some-atom)]
Works a treat. Is often better than using println
s
Final warning; to use pprint
you'll need to be using a recent version of cljs. Something from the last few weeks.
In re-frame, we use a Big Atom (or Ratom), app-db, to hold all state . Is it okay to leave a user's (say) password in app-db? Or should that be sent directly to, and stored in, the server?
@sooheon: ditto what Mike said about the middleware. Re-frame is a really logical way to hold the app state, but I wrote my event handlers wrong at first. The middleware debug
is quite helpful, as it immediately shows in-console any mistakes.
@coyotespike: Thanks, I’ll be sure to learn it. I’m interested in your sensitive info question as well, now that you mention it.
when the password is created, i send it to the server and dissoc the key from app-db. We send back a token which is stored in the app-state
if your app-db looks like
{... :user {:user "map" :in "here}}
you could have a subscription that gets :user and uses select-keys so that you never have to worry about undesirable map entries slipping through@escherize: that makes sense. Could you elaborate a bit on the token you send and how you use it? And to confirm, you're suggesting using select-keys as a safer way to store the password client-side?
select-keys is good because it tells you explicitly what the subscription will return
you might end up with :a and 😛 being nil, but you know a lot about m from that function
man, did you just put together that flow-chart? that's awesome
oh, that's pretty...I feel an M-x package-install
coming on...
Thanks for the extra explanation, I'll implement something like that (adding user login right now)
yeah it feels weird to treat the password totally different but its worked out for me so far
@meow, @mikethompson, re: re-com with boot, boot was choking on the outdated dependency for cljs-time. PR in progress :)