This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-07-06
Channels
- # beginners (90)
- # boot (83)
- # cider (39)
- # clara (4)
- # cljs-dev (124)
- # cljsrn (10)
- # clojure (208)
- # clojure-boston (1)
- # clojure-italy (13)
- # clojure-nlp (3)
- # clojure-russia (34)
- # clojure-spec (63)
- # clojure-uk (101)
- # clojurescript (65)
- # community-development (13)
- # copenhagen-clojurians (1)
- # core-async (1)
- # cursive (24)
- # datascript (1)
- # datomic (65)
- # emacs (20)
- # graphql (20)
- # hoplon (21)
- # instaparse (18)
- # jobs (5)
- # jobs-discuss (2)
- # leiningen (8)
- # luminus (32)
- # midje (1)
- # mount (3)
- # off-topic (18)
- # om (10)
- # parinfer (6)
- # pedestal (2)
- # planck (2)
- # precept (22)
- # protorepl (7)
- # re-frame (45)
- # reagent (9)
- # ring (1)
- # ring-swagger (4)
- # rum (2)
- # spacemacs (5)
- # sql (2)
- # unrepl (13)
- # untangled (8)
- # yada (5)
@mattly @bradleesand These days the best way to write that view functions is:
(defn item-rows
[row]
(let [visible-cols @(rf/subscribe [::visible-columns])] ;; I put an @ on the front of the subscribe too
[:div.col-container]
;; ... contents inside of here
))
Ie. no need to use Form-2I just pieced together a nice re-implementation of https://github.com/martinklepsch/s3-beam that suites my needs just fine, when I realized I hit a snag and I’m not quite sure how to get around it in a nice re-frame approach
long story short, once the upload is done I need access to the storage key for the just uploaded file so I can send it along to the backend with the rest of the data
kennethkalmer: I'm also interested in a solution to this - when I use async-flow-fx, sometimes I need to use results from a previous event
at the moment I find a place in the db to put it
but that feels kinda messy
I’m not willing to do that! I started typing that out and thought I’d rather take a timeout and think this through properly
the uploader component does the entire dance in isolation, and I patiently wait thanks to re-frame-async-flow-fx before submitting
just that storage key…
so s3-beam uses core.async under the hood, and now it makes a lot of sense to me… I guess ideally/naively I’d like to fire off the upload process in an event handler and wait for it to complete before carrying on… I get that with async-flow-fx, except that everything is silo’ed off from each other. Now I’m considering using core.async too to wait for the storage-key (or an error) before carrying on. This replaces the async-flow, but feels a completely different to the rest of the app and I’d like to avoid that
alternative is to dispatch the upload process with everything needed to complete the final api call later by having the chain dispatching continuously until complete, this also feels messy
kennethkalmer: haha yes definitely we've hit the same limitation as I think I've tried this approach too
have you any inkling what might work?
so far only dispatching everything, maybe using an effect handler can make it look better
how do you dispatch everything - where do you get the storage key from? Or do you mean not using async-flow-fx and just using a series of dispatches
yeah, drop async-flow-fx in this case
mm yeah I've switched back and forth between this and async flow
defining everything at the top/co-ordination level sure feels better and helps keep the individual handlers small and ignorant/decoupled
I wonder if async-flow could be extended a bit so you could bind or collect information from the individual handlers
Me too, I’m already leaning on the just released 0.0.8 for the events predicate function functionality…
kennethkalmer: ooh I didn't know about this new thing
for each file/attachment I create a unique identifier with gensym
and that gets dispatched along every step of the way and used in the app-db to track upload progress, etc… so my async-flow’s need to match the correct identifier in case of multiple uploads running concurrently
I don’t have concurrent uploads yet, but that is kinda the very next step
Something that looks a bit like this, perhaps
{:when :seen :events [:upload/success storage-key]
:dispatch [:backend/set-storage-key storage-key] :halt? true}
I don’t have storage-key at this stage of the match
mm that was fanciful anyway, wondering what something would look like if you wanted to locally bind bits of the result
{:first-dispatch [:upload/start identifier file]
:rules
[{:when :seen?
:events [(fn [[e i _]]
(= [e i] [:upload/done identifier]))]
:dispatch [::create-folder params]}
{:when :seen?
:events [::folder-created]
:halt? true}
{:when :seen-any-of?
:events [[:upload/failed identifier] ::request-failed]
:halt? true}]}
:upload/done
gets dispatched with the storage key, that was my first naive attempt
hence the predicate check in the events, the _
is the storage key but doesn’t matter when the flow is defined
wishful thinking - if "custom-dispatch" existed?
{:first-dispatch [:upload/start identifier file]
:rules
[{:custom-dispatch (fn [[event identifier & args]]
(when (= [e i] [:upload/done identifier])
(let [[storage-key] args]
[::folder-created storage-key])))}
{:when :seen?
:events [::folder-created]
:halt? true}
{:when :seen-any-of?
:events [[:upload/failed identifier] ::request-failed]
:halt? true}]}
Or :dispatch
could just accept an fn, just like events could be a fn that acts as a predicate
@kennethkalmer I've made a fork of re-frame-flow-fx that does this
it provides an extra dispatch rule, :dispatch-fn which takes the seen event and returns a seq of events to dispatch
I wonder if @danielcompton has any thoughts on this situation
Hmm, I’m gonna sketch out what it could look like with a :upload-file
effect to smooth over any verboseness in the handler
@mikethompson yeah I'm still on 0.8, I haven't budgeted time to upgrade to 0.9.x yet
@kennethkalmer would be happy to take a PR on s3-beam to see your re-frame approach to this, we've got something internally we use for re-frame
but we haven't converted it to use effects
@danielcompton, maybe I'll start with a gist of the component and how it I use it to kick off some ideas
Will do that in the morning, knackered atm