clojure-uk

A place for people in the UK, near the UK, visiting the UK, planning to visit the UK or just vaguely interested to randomly chat about things (often vi and emacs, occasionally clojure). More general the #ldnclj
2021-02-20T00:23:06.408800Z

thanks ๐Ÿ˜ƒ... It's really hard to tell how popular core async is, some people swear by it and others seem to avoid it like the plague. I'll dig into using promesa, I was specifically thinking of core.async because it's transducer compatible, basically my thought process was build up a stack of xforms and then apply them. Perhaps I can do the same with promises? :thinking_face:

jiriknesl 2021-02-20T05:48:42.002100Z

I think the description might not be absolutely accurate. So letโ€™s imagine one is setting up user session data storage. Itโ€™s empty. I will use load to get data to the storage (obviously from some other storage like a file or a database). When I debug and want to get all data there, Iโ€™ll call dump.

dominicm 2021-02-20T10:21:32.002200Z

Oh nice, i'd been wondering about this. Always knew it would be possible, but wasn't sure if it existed.

mccraigmccraig 2021-02-20T13:56:15.002400Z

i use both of them - i like core.async for stream-like things (e.g. a stream of events, or a stream of file buffers), but i find it awkward for promise-like things (e.g. a single http request)

mccraigmccraig 2021-02-20T13:58:36.002600Z

basically i really like the manifold programming model, which uses both promises (aka Deferred and Stream together - and it's fine to use core.async and promesa together to similar effect in cljs, although you won't get the automatic glue that manifold gives you (e.g. a reduce of a Stream returns a Deferred)

mccraigmccraig 2021-02-20T14:00:03.002800Z

i'm currently working on a thing which will give you a manifold-like model, but cross-platform and with contextual programming benefits, but it's not going to be ready for a while yet

mccraigmccraig 2021-02-20T14:03:51.003Z

for file-handling my ideal API would be based around promises, and where content streaming is required, promises of core.async chans

mccraigmccraig 2021-02-20T14:05:05.003200Z

e.g. file/exists? returns promise<bool>, file/content-stream returns promise<chan<buffer>>

2021-02-20T15:29:46.003400Z

Ah, that might not be a good fit then, the files in question are file objects that you would get from within a browser context of an upload or drag-n-drop event, so perhaps core.async might be a better fit?

2021-02-20T15:30:05.003600Z

Those events give you individual files or an array of files

mccraigmccraig 2021-02-20T18:42:31.004Z

not sure without more details - but if you've got more detail i'm happy to give you my take

2021-02-20T23:46:29.004400Z

Sure ๐Ÿ˜ƒ... Let me know what details you need and if the explanation that I give below is insufficient ๐Ÿ˜ƒ... I've got lots of Files[0] and a stack of transforms that I run which I'm then using to create blobs[1]. I don't quite know what transforms I'm running until later, but sometimes I need information about the file contents to work that out. Then once I build the appropriate transform stack I then run all the transforms on the file contents to build a blob which I then use to trigger a download. My current approach is to just read the file contents and then use that to work everything out, but of course for large files you can't just do that because you'll crash the browser tab with an OOM. So I'm thinking can I build a xform of any transformations I want to run on the file and then apply them to the file in chunks, using slice, or just a stream. One potential bit of fiddliness is that I might have to do this more than once, as some intermediate steps towards building the xform may require me to run the current xform state across the whole file to work out what the next step is.:thinking_face: - [0]: https://developer.mozilla.org/en-US/docs/Web/API/File - [1]: https://developer.mozilla.org/en-US/docs/Web/API/Blob