This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
@phil The figwheel template is pretty good for a bare bones starting point. I've also used the reagent template.
@phil: Also there's Luminus template for Reagent.
I'm wondering - I'm using re-frame and would like to achieve the following behaviour: After some event happens - I'm changing app state in a event handler function. Because of that - one of the components get's selected (this is a virtual selection, no related to browser focus). It might happen that this element will be out of the page fragment that the user is looking at. So I'd like to scroll the page to make this element visible. But how to do that using re-frame - I have no idea where to start. Maybe someone of you has?
One way to do it would be to record the selection change in app state and when rendering in componentdidupdate doing the scroll and dispatching component selection handled event to remove the temporary state in app state. Though it feels rather inelegant.
@mateusz-fiolka why inelegant? Your solution sounds good.
@zoldar: Because it's sounds like too many steps for such seemingly not complicated feature.
@ambrosebs how do you mean "evaluate clojure code from clojurescript"? I guess it'll depend on the js environment you're running in?
I don't know what JS offers tbh. I was thinking start a Clojure nREPL server, then pipe evaluations to it via a socket from CLJS.
You can probably talk to nREPL easily from node. There's probably a more direct route if you're on nashorn or rhino. Perhaps websockets for browser envs
@ambrosebs: if you’re on Nashorn you can probably access the clojure compiler directly: https://docs.oracle.com/javase/8/docs/technotes/guides/scripting/nashorn/api.html
jonas: right, this was more a thought exercise in what combinations of host/checking languages is possible with core.typed
@mateusz-fiolka you could create an async channel in app state and setup a loop in will-mount of component responsible for scrolling. That way you just push scroll command to that queue
is anyone here transpiling to clojurescript from some other language? how would you get source map support for that?
@zoldar: Another problem is that domnode is not accessible from react as far as I understood.
@mateusz-fiolka: what do you mean?
@zoldar: To get current widget location I'd need to have dom node, not only render function.
@mateusz-fiolka: DOM is accessible - see reagent.core/dom-node
@zoldar: Thanks, I'll check it.
@mateusz-fiolka: first argument to component lifecycle methods (like will-mount, did-mount, did-component-update etc.) is the underyling React component and it's possible to access underlying DOM node calling .getDOMNode method on it - reagent.core/dom-node is a simple convenience for that.
@zoldar: Awesome, I'm already using 3-rd form component.
quick question: is it better to start with reactjs and then switch to om/reagent or to start directly with om/reagent? I mean for studying purposes.
@mdallastella: The general consensus is to at least read through the reactjs docs. Personally I think this is right. The lifecycle of a react component leaks (not in a negative way) through to both libraries for example.
@colin.yates: I see, thanks
@mdallastella: Also, a lot of people start with om and then move onto reagent. I did, and then moved onto re-frame. Any of those three though will rock your world 😉
it also includes helpers to merge source maps together. The intention was for it to be generic, but it may be that it only works for merging two source maps. Happy to see it people enhance it if that's the case.
is merging transitive? or is that what you mean by "it may be that it only works for merging two"
https://github.com/clojure/clojurescript/blob/master/src/main/clojure/cljs/source_map.clj#L288
Structure is generic so I don't see why it wouldn't work https://github.com/clojure/clojurescript/blob/master/src/main/clojure/cljs/source_map.clj#L12
dnolen: would i add source map metadata to the bottom of the generated cljs source file, and the browser would follow that transitively?
and i generate the .haml --> .cljs source mapping and add it to the bottom of the .cljs file?
I am using om and want to load my data using cljs-ajax from an api … I have set a handler function to get the result of the GET call .. how do I use it to set the app state?
@clojuregeek: if that's a one-time load, you can put that GET call in component's will-mount method
@clojuregeek: from there, just call om/transact! (or other function altering app state or component's local state) to populate state with data from the ajax call
ok thanks.. i’ll try that..
Im use core.async for that, put channel consumer to will-mount method and share channel with all component children. Call GET method and put result into channel in callback
Fighting with cljs trying to get a browser REPL working 😐. Here's what I tried:
(use 'figwheel-sidecar.repl-api)
=> nil
(cljs-repl)
NullPointerException clojure.core/deref-future (core.clj:2184)
@zoldar: I have this … http://screencast.com/t/vtsONT4RHj then in console
XHR finished loading: GET "".goog.net.XhrIo.send @ xhrio.js:561goog.net.XhrIo.ajax$core$AjaxImpl$_js_ajax_request$arity$7 @ core.cljs:61ajax$core$_js_ajax_request @ core.cljs:21ajax$core$ajax_request @ core.cljs:376ajax$core$easy_ajax_request @ core.cljs:441ajax.core.GET.cljs$core$IFn$_invoke$arity$variadic @ core.cljs:447ajax$core$GET @ core.cljs:447recipes_om$core$get_data @ core.cljs:25(anonymous function) @ VM7088:1(anonymous function) @ VM7088:9(anonymous function) @ VM7088:14figwheel$client$eval_javascript_STAR__STAR_ @ client.cljs:116figwheel.client.repl_plugin @ client.cljs:142(anonymous function) @ client.cljs:305cljs.core.Atom.cljs$core$IWatchable$_notify_watches$arity$3 @ core.cljs:3478cljs$core$_notify_watches @ core.cljs:397cljs$core$reset_BANG_ @ core.cljs:3509cljs.core.swap_BANG_.cljs$core$IFn$_invoke$arity$3 @ core.cljs:3493cljs$core$swap_BANG_ @ core.cljs:3491(anonymous function) @ socket.cljs:62
core.cljs:901 Uncaught Error: Assert failed: (transactable? cursor)
When running lein figwheel
, is it still necessary to run a separate repl to enable a browser-repl?
@clojuregeek: where is app
coming from? if handler is defined as a top form, it's undefined
@clojuregeek: if you're calling get-data
in component's will-mount
, pass app-state to it, then pass it to handler
@clojuregeek: alternatively, you could simply swap!
the app-state atom directly