Replies: 1 comment 1 reply
-
A lot of browser APIs, such as async File related stuff, is promise-based so at some level you have to deal with the promises. I use promesa. In terms of integrating it into re-frame I think the best way is an effect handler ( (reg-fx
:chunked-file-reader
(fn [{:keys [on-chunk on-complete on-failure}]
...
;; on each chunk
(dispatch (conj on-chunk the-chunk))
))
(reg-event-fx
:read-file
(fn [cofx event]
{:chunked-file-reader {:on-chunk [:file-chunk]
:on-complete [:file-complete]}})) |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I've been using core.async and promises a lot to use the FileReader, File and Blob api's.
However I do wonder if there's a better way of handling it that fit's more cleanly into how re-frame works.
One especially significant bugbear that I've not figured out how to get working is doing chunked reading.
Splitting up a longer task within re-frame and processing it in chunks is straightforward, but I've not figure out how to map this to the file api.
Any suggestions?
Beta Was this translation helpful? Give feedback.
All reactions