Fork me on GitHub
#re-frame
<
2020-06-08
>
Spaceman04:06:13

This expression:

(.val (js/jQuery (str "delivery" (:num-delivery-addresses db))) (:description suggestion))
in my fx handler gives the following error:
Uncaught Error: [object Object] is not ISeqable
    at Object.cljs$core$seq [as seq] (core.cljs:1226)
    at re_frame$fx$do_fx_after (fx.cljc:74)
    at Object.re_frame$interceptor$invoke_interceptor_fn [as invoke_interceptor_fn] (interceptor.cljc:71)
    at Object.re_frame$interceptor$invoke_interceptors [as invoke_interceptors] (interceptor.cljc:109)
    at Object.re_frame$interceptor$execute [as execute] (interceptor.cljc:204)
    at Object.re_frame$events$handle [as handle] (events.cljc:65)
    at Object.eval [as re_frame$router$IEventQueue$_process_1st_event_in_queue$arity$1] (router.cljc:179)
    at Object.eval [as re_frame$router$IEventQueue$_run_queue$arity$1] (router.cljc:198)
    at eval (router.cljc:146)
    at Object.eval [as re_frame$router$IEventQueue$_fsm_trigger$arity$3] (router.cljc:169)
cljs$core$seq @ core.cljs:1226
re_frame$fx$do_fx_after @ fx.cljc:74
re_frame$interceptor$invoke_interceptor_fn @ interceptor.cljc:71
re_frame$interceptor$invoke_interceptors @ interceptor.cljc:109
re_frame$interceptor$execute @ interceptor.cljc:204
re_frame$events$handle @ events.cljc:65
eval @ router.cljc:179
eval @ router.cljc:198
eval @ router.cljc:146
eval @ router.cljc:169
G__67540 @ router.cljc:187
channel.port1.onmessage @ nexttick.js:218
Why would that be?

dpsutton04:06:16

can you give the rest of the fx handler?

Spaceman04:06:10

(re-frame.core/reg-event-fx :show-next-delivery-panel! (clojure.core/fn [{:keys [db]} [___68401__auto__ suggestion]] (prn "suggestion is " suggestion) (prn "description is " (:description suggestion)) (prn "db is" db) (prn "num delivery addresses " (:num-delivery-addresses db)) (prn "id is " (str "delivery" (:num-delivery-addresses db))) (prn (js/jQuery (str "delivery" (:num-delivery-addresses db)))) (.val (js/jQuery (str "delivery" (:num-delivery-addresses db))) (:description suggestion))))

Spaceman04:06:37

formatting is inconvenient because macroexpanded

Spaceman04:06:29

That's better:

(reg-event-fx :show-next-delivery-panel! 
    (fn [{:keys [db]} [___68401__auto__ suggestion]] 
        (prn "suggestion is " suggestion) 
        (prn "description is " (:description suggestion)) 
        (prn "db is" db) 
        (prn "num delivery addresses " (:num-delivery-addresses db)) 
        (prn "id is " (str "delivery" (:num-delivery-addresses db))) 
        (prn (js/jQuery (str "delivery" (:num-delivery-addresses db)))) 
        (.val (js/jQuery (str "delivery" (:num-delivery-addresses db))) (:description suggestion))))

dpsutton04:06:34

are you seeing any of the prn expressions?

dpsutton04:06:44

do you see "db is ..."?

Spaceman04:06:28

it's a regular map

dpsutton04:06:36

does it print?

dpsutton04:06:49

i'm interested if the error is before or after that print statement

Spaceman04:06:18

if I comment out all the jQuery stuff, the error disappears

dpsutton04:06:31

reg-event-fx must return effects

(reg-event-fx              ;; -fx registration, not -db registration
  :my-event
  (fn [cofx [_ a]]        ;; 1st argument is coeffects, instead of db
    {:db       (assoc (:db cofx) :flag  a)
     :dispatch [:do-something-else 3]}))
you are returning whatever (.val js/jQuery ...) returns

dpsutton04:06:40

and its an object and not sequable like the map is

Spaceman05:06:22

sorry dumb mistake.

dpsutton05:06:14

i just went to the documentation and it was clear your mistake. re-frame's docs are very good

Spaceman05:06:04

especially now

andre08:06:06

Real world react native application built with clojurescript and re-frame https://github.com/flexsurfer/conduitrn

🎉 4
andre08:06:29

its a port of web application, so you can see a difference between web and RN re-frame applications

mikethompson11:06:12

@andre Good time for me to add this to re-frame resources?

andre11:06:35

why not 🙂

mikethompson11:06:19

Will push a bit later today

Spaceman18:06:59

@andre how is it similar to or different from re-natal?

andre19:06:24

completely different

andre19:06:31

shadow-cljs is just like a new level

Spaceman19:06:29

what do you mean?

Spaceman19:06:18

I'm looking for a re-natal-like template that works with shadow-cljs rather than figwheel

thheller19:06:50

@pshar10 you don't need re-natal at all. just use shadow-cljs as normal. there are some example projects that do.

Spaceman19:06:18

@thheller would you please share some that are straightforward to set up?

Spaceman19:06:44

a template that has clear instructions about how it works?

Spaceman19:06:17

and can be deployed with relative ease on Android and iOS app stores?

thheller19:06:16

I don't do react-native myself so I have no clue how to do any of that

Spaceman19:06:39

someone's got to know @thheller

thheller20:06:20

well the react-native docs should have all of that. you just do whatever that tells you. shadow-cljs just produces one output file that is included normally. everything else is up to react-native tooling.

Spaceman20:06:14

yeah but I don't want to reinvent the wheel

Spaceman20:06:01

@neo2551 what are these steroid functions?

David Pham20:06:43

It gives you a template for RN and also some helpers for using re frame with RN (navigation is tricky)

David Pham20:06:33

It is straightforward to setup as you asked.

Spaceman20:06:04

okay thanks but I want to do a breadth first search of all my options

David Pham20:06:31

My guess is you need to experiment a bit to get the ideas and the constraints of RN and CLJS and once you have some experience you can create your own template or judge the quality of each.

Spaceman20:06:05

@neo2551 what are some glaring constraints of RN and CLJS

David Pham20:06:43

CLJS idioms are usually incompatible with many examples of RN in my opinion. This is mostly because example are done in JS/TS with OOP model.

Spaceman21:06:06

concretely?