Fork me on GitHub
#re-frame
<
2016-11-15
>
seantempesta07:11:50

Is there a way to remove the global reference to the re-frame.db/app-db? I’m trying to use Stuart Sierra’s Component library with re-frame, and it feel like a hack directly modifying the global state to reset it. Also, I’m trying to use datascript and it feel wrong to (swap! re-frame.db/app-db assoc :ds-db datascript-db) into it just so I can access it from within handlers and subscriptions. Ideally, I’d be able to pass in whatever data structure I want and have that handed over to handlers and subscriptions.

mikethompson07:11:46

We developed https://github.com/Day8/re-frame-async-flow-fx for use with re-frame - it is similar in intent to Component in terms of setup, but it doesn't have a teardown part.

mikethompson07:11:52

To "inject" a datascript connection into an event handler, I'd be using an Interceptor which adds the connection to the coeffects

mikethompson07:11:29

That's how app-db is made available ... an interceptor adds it to the coeffeects

seantempesta07:11:11

Cool. I’ll look into this. Thanks!

yenda07:11:22

I am trying to use a javascript library to render a document in a component in my app. the problem is that the div where the document is rendered is targeted with jquery. It works the first time I go into a pannel but the second time it seems like jquery doesn't find the div anymore but it is still there.

yenda07:11:37

I tried using a tier 3 component but then the component doesn't update when the document becomes available

andre07:11:47

@danielcompton yes. but it will not work out of the box with the undo/redo 😞

yenda07:11:57

it does update when I revisit the page

andre07:11:24

@ericfode yes, I was inspired by elm conference and their debugger. but I think not all using def-view macro, I think this is a really useful thing. for me at least 🙂

yenda08:11:27

why doesn't my component update when diagram changes ?

andre08:11:46

can you provide the code of function where you call diagram-view

yenda08:11:12

using prints I noticed that diagram in :reagent-render is there but in component-did-update it is nil

yenda08:11:36

note that the first time I visit the page an event ask for the diagram with ajax so it is nil, and is added to instance via the subscription

yenda08:11:46

the reason I am trying to call utils/diagram-view after mount is because it is an external js lib that grabs the div with xquery

yenda08:11:29

is it possible that component-did-update is still using the old value of diagram (nil) ?

yenda08:11:26

Seems more of a reagent question I will ask on the dedicated chan

yenda08:11:54

actually I figured a fix in case someone is interested but I am not sure I like it:

yenda08:11:50

that way diagram-view is only rendered when diagram exists and the jquery selector is only applied after mount.

olegakbarov15:11:12

guys, im trying to make a dead simple dev server for SPA with re-frame and i stumbled upon the routing problem i just want to serve css and js as asstets and on all other request return index.html (for client-side routing) how should i configure my server? this doesn’t work for me

(defn handler [request]
  {:status 200
   :headers {"Content-Type" "text/html"}
   :body (slurp ( "resources/index.html"))})

(defroutes routes
  (context "/static" []
    (route/resources "/css" {:root "css"})
    (route/resources "/js" {:root "js"}))
  (GET "/*" [] handler))

(def wrapped-routes
  (-> routes
      (wrap-content-type)))

olegakbarov15:11:16

it’s funny. i just want to serve a couple of files 😁