Fork me on GitHub
#re-frame
<
2017-10-05
>
lovuikeng00:10:17

Did you try (1) edit update the default-db in db.cljs (2) save the file (3) reload the page if not already have?

lilactown02:10:10

yes, I've done both

lovuikeng02:10:18

how about > lein clean

lovuikeng03:10:28

and in repl, dev:cljs.user=> re-frame.db/app-db

lovuikeng03:10:00

if you still seeing old value, close browser and reload again

lilactown05:10:49

wow ok... i think it was something to do with caching

lilactown05:10:32

ctrl+shift+r finally got it to show my changes 😖

lovuikeng05:10:53

you have +re-frisk to go with the template? it's another way to check your app-db states

rnagpal15:10:00

If I get new data in subscription in Third Form Reagent component, will my :component-will-receive-props or :component-will-update be called ?

lovuikeng15:10:11

I'd suggest to go with semantic-ui-react with tips from @kennethkalmer https://opensourcery.co.za/2017/02/12/using-semantic-ui-react-with-re-frame/

rnagpal16:10:18

I added console statements in various methods of component I see the render console statement called first and then the component did mount and I don’t see the component will receive props called after but the component is rendered with new re-frame subscription data

sandbags16:10:25

in any scenario just dispatching :initalize-db should do it, but yes i've found the caching situation problematic too

rnagpal16:10:17

Here is the code

(fn [opts]
  (let [data-sub (re-frame/subscribe [::data-sub])
        show-loading? (reagent/atom false)]
    (reagent/create-class
      {:display-name "generic-loading-component"
       :component-did-mount
       (fn component-did-mount [_]
         (js/console.log "In component-did-mount of loading")
         (when-not @show-loading?
           (js/setTimeout #(when-not @node-events
                             (reset! show-loading? true))
                          100)))
       :component-will-receive-props
       (fn component-will-receive-props [_]
         (js/console.log "In component-will-receive-props of loading")
         (when @node-events
           (js/console.log "reset show loading to false")
           (reset! show-loading? false)))

       :component-will-update
       (fn component-will-update [_]
         (js/console.log "In component-will-update of loading")
         (when @node-events (js/console.log "reset show loading to false")
                            (reset! show-loading? false)))

       :reagent-render
       (fn [opts]
         (js/console.log "In Render of loading")
         (if @show-loading? [:div "LOADING"]
                            [show-data @data-sub opts]))})))

rnagpal16:10:54

So in case of subscription data change does the react lifecycle not come into picture ?

isak17:10:56

(having inner and outer components)

rnagpal18:10:25

Thanks @isak Stateful components can be done in just one component also

rnagpal18:10:58

Is the reason to split it into two components, is to make sure react lifecycle is adhered ?

isak19:10:04

@rnagpal My understanding is yes, but in general I just wouldn't have any expectation that prop lifecycle methods would be called for normal re-frame subscription updates, because that would be an implementation detail imo. But if you pass props, then it is different.

colbydehart21:10:55

I am having a bit of trouble here. I set up a new re-frame project from the template with the +handler option, hoping to set up a small compojure API for my re-frame app, I installed ring-json and have a handler that looks like this.

(defn api []
  (compojure.core/routes
   (GET "/" [] {:status "OK"})))

(defroutes routes
  (context "/api/v1/" [] (api))
  (GET "/" [] (resource-response "index.html" {:root "public"}))
  (resources "/"))

(def dev-handler (-> #'routes wrap-reload))

(def handler routes)
I feel that with figwheel running and the :ring-handler option set to this handler, i would be able to hit localhost:3449/api/v1 and get back a JSON payload of {"status": "ok"} but I am instead getting a 404. Maybe It is something wrong with my understanding of Ring handlers + the compojure context, or am I supposed to be hitting another port for ring besides 3449 when running in dev mode?

lovuikeng23:10:18

sorry, @colbydehart, you'd need to have ring server be running on port 3000 on a separate console by $ lein run