Fork me on GitHub
#re-frame
<
2017-05-02
>
madstap00:05:52

@eveko Did you figure out your problem? The first argument of a reg-event-fx is not the db, but a map of coeffects, which contains the db. Changing [db [_ logindata]] to [{:keys [db]} [_ logindata]] should work.

wasser02:05:13

@hkjels possibly because (take) produces a lazy sequence. See https://stuartsierra.com/2015/08/25/clojure-donts-lazy-effects for more.

boyanb08:05:01

Morning guys. I'm a bit curios if there is an http-xhrio implementation equivalent for cljs-http. It seems fairly straight forward to do, but has somebody done the work already?

mikepence14:05:20

I am trying to translate this bit of JS logic to re-frame and cljs:

var osd = OpenSeadragon({
        id: "openseadragon1",
        prefixUrl: "vendor/js/openseadragon-bin-2.2.1/images/"});
Aside from invoking cljs equivalent code, I am wondering where to put that code. It needs to run once, at the beginning of the lifecycle of the re-frame app, but references an element by id that must already be rendered.

mikepence14:05:47

it is a bit of a chicken v. egg problem

mikepence14:05:29

hmm, I seem to be able to reference the id "openseadragon1" even though it is generated in my reframe views

mikepence15:05:17

so the issue seems to be that I need to do some initialization stuff for that var, but can't do that in the viewer.core init

souenzzo15:05:32

Not sure if I understand, but: On reagent/react you can pass [:div {:id "abc" :ref callback}] where callback is a function that receives one argument, that argument was the element.

mikepence15:05:52

that may help. thanks.

mikepence15:05:34

so now I have these callback handlers:

(defn add-osd-handlers []
  (.addHandler js/osd "open" osd-open-success)
  (.addHandler js/osd "open-failed" osd-open-failure))

mikepence15:05:57

I need to call them post re-frame app-init, and only once

mikepence15:05:36

I might just go fishing in the re-frame source for a good place to have those

souenzzo15:05:40

(defn render-file
    []
    (let [id "textarea"
          txt @(subscribe [:app/text-area])
          settings @(subscribe [:app/editor-settings])
          args (clj->js settings)]
      (reagent/create-class {:component-did-mount (fn [e]
                                                    (let [el (aget e id)]
                                                      (doto (.fromTextArea js/CodeMirror el args)
                                                        (.on "change" #(dispatch [:app/save-file (.getValue %)])))))
                             :render              (fn [this]
                                                    [:div [:textarea {:value txt
                                                                      ;; when it render first time, will call :ref fn
                                                                      :ref   #(aset this id %)}]])})))

souenzzo15:05:25

My use case. I also not really sure if it's the "right way", but works fine. If you find something "better", please share 🙂

souenzzo15:05:41

in component-did-mount, this was a better name then e

mikepence16:05:05

is there a simple way to tag an html element to tell react not to update it?

mikepence17:05:56

I need to attach a handler to that component that indicates that shouldComponentUpdate: false or something akin to that.

mikepence17:05:09

possibly, having the node subscribe to a value that never changes could do it, according to my understanding of https://github.com/Day8/re-frame/wiki/When-do-components-update%3F

polymeris17:05:32

Hi. There is this project called RealWorld, which is sort of like a more complete (and fullstack) TodoMVC example app https://github.com/gothinkster/realworld

polymeris17:05:06

As an exercise, I have started a re-frame implementation at https://github.com/polymeris/re-frame-realword-example-app

polymeris17:05:21

I am no expert in cljs or re-frame, though, so if anyone has some spare time and wants to review it, I'd appreciate it

polymeris17:05:30

Eventually it might serve as an example app for re-frame

pesterhazy17:05:26

what other famous example apps are there?

pesterhazy17:05:37

TodoMVC, Java's Pet Store

rc114018:05:32

hi all , does anyone here know how to implement the android part of this react-native-plugin (https://github.com/zo0r/react-native-push-notification ) in re-frame

rc114018:05:02

i have seen a bunch of examples that all only seem to implement the iOS part

rc114018:05:15

i cant see how to implement the class override specifically

rc114018:05:33

i know it mentions only if i did not use the link command manually , just not sure if that applies to re-frame or not, referring to this statement [Manually register module in MainApplication.java (if you did not use react-native link)]

pesterhazy20:05:25

might be better to ask in #cljsrn

sashton21:05:57

what does d-vec represent here:

(reg-sub
       :a-b-sub
       (fn [q-vec d-vec]
         [(subs/subscribe [:a-sub])
          (subs/subscribe [:b-sub])])
       (fn [[a b] [_]] {:a a :b b}))

sashton22:05:27

when running/printing it out, i just get nil

sashton22:05:19

oh, nvm… dyn-vec 🦆

danielcompton22:05:44

Now that you can subscribe within a form-1 component, there aren't too many use cases left for dynamic parameters

danielcompton22:05:00

as your standard parameters become dynamic