Fork me on GitHub
#re-frame
<
2017-05-16
>
pesterhazy08:05:17

there shouldn't be problems mixing "display: table" and "display: flex" I think

sandbags08:05:03

@pesterhazy thanks, my initial experiments with using [:table ...] seemed to work but i wasn't sure if i was storing up trouble

danielneal08:05:00

I have a question about "subscribing to external data" https://github.com/Day8/re-frame/blob/master/docs/Subscribing-To-External-Data.md Will the following approach work as the params change?

(defn recipe [props]
  (let [{:keys [params]} props
        {:keys [recipe-id]} params
        recipe (subscribe [:graphql {:query "query recipe ($recipe_id:String!) { recipe (recipe_id:$recipe-id) { intro method }}"
                                      :variables {:recipe-id recipe-id}}])]
    (fn []
      (let [{:keys [introduction method]} @recipe]
         [rn/view
            [rn/text introduction]
                   ...    ])))
(implementation not written yet, just not sure if I've understood what happens with the "subscribe to external data" as the params change - will the "subscribe" get the most recent props.

danielneal08:05:29

and how does this fit in with the *-fx /handlers/keeping the side-effectful stuff pushed to the edge of the system

mccraigmccraig09:05:42

in a form-2 component @danieleneal your inner render fn needs to take the exact same params as the outer render fn - the outer fn gets called once on component creation, and the inner fn on every render - so the value of @recipe will change and the props passed to the inner fn will change, but if you want your recipe subscription to change based on the updated props that will not happen - you have to create a new component or use a dynamic subscription

mccraigmccraig09:05:16

in re-frame >0.8 you can use subscribe in form-1 components though - see https://github.com/Day8/re-frame/issues/218

danielneal09:05:34

mm yeah, that makes sense.

danielneal09:05:56

So I can use subscribe directly in a form one component

danielneal09:05:26

something about that feels a bit strange

danielneal09:05:18

I'm still at the beginning of using re-frame, trying to get idiomatic usage

danielneal09:05:38

I enjoyed reading the stuff about effectful handlers,

danielneal09:05:03

I'm not sure I've completely 'got' how to do everything as cleanly with subscriptions yet

mccraigmccraig09:05:21

it takes some practice - did for me anyway 🙂

danielneal09:05:52

So if I flatten everything out like this .... it should just work

danielneal09:05:54

(defn recipe [props]
  (let [{:keys [params]} props
        {:keys [recipe-id]} params
        recipe (subscribe [:graphql {:query "query recipe ($recipe_id:String!) { recipe (recipe_id:$recipe-id) { introduction method } }"
                                     :variables {:recipe-id recipe-id}}])
        {:keys [loading? response]} @recipe
        {:keys [introduction]} response]
    [rn/view
     (if loading?
       [rn/activity-indicator]
       [rn/text introduction])]))

mccraigmccraig09:05:25

yes - you can do those destructures in one hit too with the longhand destructure syntax (i prefer it for deeper destructures) e.g. {{recipe-id :recipe-id} :params} and {{introduction :introduction} :response loading? :loading?}

danielneal09:05:08

ah this looks interesting/close to what I had more in mind after reading the effectful handler stuff https://github.com/Day8/re-frame/issues/255#issuecomment-274303581

lumpy13:05:03

I’m writing my first re-frame app. I have multiple page views and separate each into it’s own NS with 3 files for each: events, subs, views, I’m guessing this is a common pattern. I find myself writing a lot of keywords that look like :search/run-search or :account/set-username I would love to write these with ::set-username but that would give me a keyword only in one of the sub namespaces, not one that can be shared amongst the 3. Is there a good workaround to make this possible. Would love a second level qualified keyword reader macro like #:run-search -> :app/search/run-search in the app.search.events NS.

owen14:05:03

@borjarus looks like you need to de-reference the subs

fabrao15:05:43

Hello all, I want to make dialog library and reading about the Effectful Handlers, do you think it´s dangerous doing this?

(defn error [title message text-button fn-return-function]
  (rf/dispatch
   [:configurar-dialogo
    {:titulo title
     :tipo :normal
     :mensagem message
     :fn-confirmar fn-return-function
     :texto-confirmar text-button}])
  (rf/dispatch [:apresentar-dialogo :erro]))
The first one dispatch is to configure dialog informations and the second one is to render the dialog. How to use it in the right way?

bradleesand15:05:17

I usually do this with one dispatch. I have an event handler that receives the name of the dialog and the configuration so it can do this all at once.

sandbags15:05:56

Hrmm... may have found a re-com bug. When adding a :tooltip to a hyperlink the hyperlink element gets indented

sandbags15:05:36

does anyone else see that? assuming anyone else is using re-com

borjarus16:05:48

@owen yes you right .. but I dereference subs inside ios-swichery component. I update my slack post and add code of this component. I've tried also dereferenced before i pass to component but final effect is same

nrako17:05:51

@borjarus I am wondering if you might need a :component-did-update function. You can see an example here - https://github.com/Day8/re-frame/blob/master/docs/Using-Stateful-JS-Components.md#example-using-google-maps

owen17:05:00

@borjarus ah didnt see that, my guess is what nrako is saying is probably correct, I'm assuming it has something to do with the create-class? what if you try

r @(re-frame/subscribe [:get-rsvp]