Fork me on GitHub
#re-frame
<
2017-01-27
>
akiroz06:01:41

anyone know if it's possible to dispatch an event only if it exists?

akiroz06:01:25

I have several panels, some has a :<panel>/initialize event, some don't.

borkdude11:01:31

Where can I find documentation about :<-?

sandbags16:01:35

@akiroz I think it's possible since IIRC re-frisk can show you the registered event handlers

sandbags16:01:29

mind you it means poking about inside re-frame.registrar to access the atom in there

sandbags16:01:45

interesting naming scheme kind->id->handler

sandbags16:01:08

i guess that works nicely for such a directed data structure

sandbags17:01:13

i guess you could use get-handler if you have a decent id scheme

borkdude17:01:28

I keep getting:

{:http-xhrio {:method :delete
                 :uri (str server-url "/api/signals/" uuid)
                 :timeout 20000
                 :request-format (json-request-format)  
                 :response-format
                 (json-response-format)
                 :on-success
                 [:signals/good-delete]
                 :on-failure [:datahub/bad-response]}
    :db db}
Uncaught Error: ["unrecognized request format: " nil] What is this?

manutter5117:01:34

Is (json-request-format) returning nil?

shaun-mahood18:01:13

@borkdude: There's some info in the todomvc example - https://github.com/Day8/re-frame/blob/master/examples/todomvc/src/todomvc/subs.cljs I'm not sure if there's anything better or more up to date though, I've been a bit out of the loop on the most recent docs changes.

borkdude18:01:29

I have isolated the problem to:

(ajax/ajax-request {:method :delete
                    :uri "/api/signals/e6ff5cf2-e484-11e6-a243-0242ac110003"
                    :timeout 20000
                    :handler (fn [[ok response]] (println response))
                    :response-format (json-response-format {:keywords? true})})

borkdude18:01:27

@manutter51 it doesn’t matter if I provide the response-format or not. It complains about the request format.

borkdude18:01:00

:request-format should be :format, DOH! That is actually not the first time I’ve had this with cljs-ajax

Rohit Thadani18:01:21

are there any examples out there where published es6 components(those that extend React.Component) have been used in reagent/re-frame. I am having a really difficult time finding one. Without this I'd just be forced into using the traditional javascript to build the app which i really dont want to do.

pesterhazy19:01:48

@rohit where are you running into trouble?

pesterhazy19:01:26

with reagent, use [:> js/MyReact.Component {:prop1 :val1 :prop2 :vl2} child1 child2 ...]

pesterhazy19:01:21

if the component expects a callback that returns an element, use r/as-element

pesterhazy19:01:27

many components are already packaged in cljsjs

pesterhazy19:01:26

be careful to pass in javascript arrays/objects etc instead of vectors/maps, if the component expects a collection

pesterhazy19:01:39

be aware of externs when you're using adv compilation

pesterhazy19:01:52

that's all there is to it really

Rohit Thadani19:01:28

I'm just looking for examples really this is good

Rohit Thadani19:01:29

did not know about [:>]

pesterhazy19:01:54

it shows how to use the (excellent) react-select component