Fork me on GitHub
#clojurescript
<
2019-05-05
>
lilactown18:05:28

I’ve been thinking about how it would be cool to be able to navigate a promise chain

lilactown18:05:22

I often have semi-long promise chains that fail somewhere in the middle and I end up having to go and add a bunch of prn or tap> to each link in the chain

lilactown18:05:54

it would be cool to be able to datafy a promise chain and it would give you the current value of the first link and the then attached to it, which you could call nav on to resolve the next link in the chain, and so on

john14:05:56

Seems like promises are often side effecting. Would you plan on firing the promise each time it's walked? Or have some data version of the chain that can be walked without executing?

lilactown14:05:09

they only fire once per instantiation, so you could resolve the next value and if it’s the first run, execute the effect maybe?

john14:05:13

Seems like it'd be a non-standard use-case... I haven't delved much into datafy/nav yet, but my expectation is that the walking is a non-side-effecting process. So you might need some explanatory language around that.

lilactown14:05:01

yeah this is all a non-starter because JS can’t block

lilactown14:05:11

it would have to be built into a tool, rather than using datafy/nav directly

lilactown15:05:55

Also nav does side effects in JVM. E.g. opening files, slurping a URI, querying a db

lilactown18:05:49

I can’t see how this would be possible with native promises, but I’m thinking about how it might be possible (if really desired) as a library