Fork me on GitHub
#re-frame
<
2016-11-24
>
andre10:11:52

want to share with you i'm working on

danielgrosse21:11:32

@knaman you have to create a subscription, which filters the alerts and then register to that one.

knaman21:11:47

@danielgrosse filter by what? alerts is simply a list of alert items

danielgrosse21:11:00

I try to get my head around the reg-event-fx function. So the cofx argument is the db, which is returned by the dispatch function?

danielgrosse21:11:15

@knaman

(reg-sub
 :newest-alerts
 :<- [:alerts]
(fn [alerts _]
(filter #(> date %) alerts))

danielgrosse21:11:18

You subscripe to this subscription in a new one, and then modify the data to the needed form. Then you can subscripe to it in your edit function

knaman21:11:51

@danielgrosse ok, but the edit is like a modal box, so that function will be called even when a new alert is added

danielgrosse21:11:58

So the edit box opens if a alert occurs?

knaman21:11:08

@danielgrosse no, there is an edit button which opens the relevant edit box

knaman21:11:06

@danielgrosse ok, seems like if dont access @alerts in side fn and instead use in let , it doesnt gets called

tomerweller22:11:29

What’s a good strategy for writing asynchronous subscription handlers? i.e, their computation function has an async call for some reason or another (io and such)

michael.heuberger22:11:15

@tomerweller set a complete flag in the app db when async fn has completed?

tomerweller23:11:04

@michael.heuberger you mean dispatching an event and subscribing for the relevant path in the db?