Fork me on GitHub
#re-frame
<
2021-12-03
>
rovanion08:12:48

New to re-frame here. Why does the initialize event have to be triggered for subscriptions to hold any data? Is there an reagent-atom created per each subscription or something along those lines?

p-himik08:12:29

Each re-frame subscription is Reagent's reaction. You have to dispatch an event that populates the app-db - otherwise, there will be no data in the app-db at all.

rovanion08:12:26

I'm not sure I understand. My app-db is populated with data upon creation:

(defonce state-atom
  (reagent/atom
   {:time       (js/Date.)  ;; current time for display                                                                                                       
    :time-color "#f88"}     ;; the colour in which the time should be shown                                                                                   
   ))

rovanion08:12:26

Because the app-db is the atom that holds all the state in re-frame lingo right?

p-himik08:12:50

This is not app-db, this is your own ratom somewhere. App-db is specifically re-frame.db/app-db - it is the source of truth for all subscriptions, it is the place that events registered with reg-event-db can change.

rovanion08:12:38

Right. You are of course right. I think I managed to confuse myself while reading the docs on state:https://day8.github.io/re-frame/application-state/

👍 2
Franklin11:12:42

hello 👋, I'm looking to add a web worker to a re-frame app I'm working on.... any pointers on where to look/what to read?

p-himik11:12:17

Web workers aren't re-frame-specific at all, as well as interaction with them. From the re-frame perspective, it's no different from e.g. WebSockets or some async API - issuing a command/event is a side-effect that should go into an effect and reacting to incoming commands/events should be done via dispatching events in some loop/callback.

Franklin14:12:17

thanks... tried to user a web worker with shadow cljs and got an error 😞 https://clojurians.slack.com/archives/C6N245JGG/p1638540659068700

roelof21:12:52

What do I do wrong here

(defn main-panel []
  [:div.columns.is-mobile.is-centered
   [:div.column.is-half
    [:div.is-two-fifths
        [:textarea.textarea :placeholder="Give me a text"]]
    [:div.is-one-fifths]
    [:div.is-one-fifths]]])
There is nothing added to the page as I can see with F12

emccue21:12:04

:placeholder="Give me a text"

emccue21:12:12

this is not jsx - this needs to be read as normal clojure code

emccue21:12:45

which the way you wrote it, it will be read as :placeholder= a keyword

roelof21:12:46

ok,e then back to the books how I can set a placeholder on the textarea

emccue21:12:53

and then a string

emccue21:12:56

you want a map

emccue21:12:05

{:placeholder "Give me a text"}

emccue21:12:20

for its one entry, key is placeholder, value is give me a text

emccue21:12:20

this higlighting might make it clearer

roelof21:12:32

thanks, some css work to do