Fork me on GitHub
Logan Powell17:11:03

👋 I'm all over the place today... Is it possible to deref a promise-chan in CLJS? I can't find any docs on dereferencing channels anywhere... The only place I've heard about it is in Rich Hickey's "Inside Transducers" talk, but I'm starving for docs... I have a use case wherein such semantics would be well suited


a promise chan can be read like any other channel


after it has been written to, it will repeatedly give that value every time it is read

Logan Powell17:11:12

In Rich's talk he said that they can also have deref'able semantics?


not in cljs


deref would have to potentially block

Logan Powell17:11:52

that's what I wanted to do 😄

Logan Powell17:11:05

I was hoping there was a "parking" deref or something


why not use a parking channel read?

Logan Powell17:11:23

but something that didn't require I wrap everything in a go block


then use take! with a callback arg?

Logan Powell17:11:50

basically, I'm being lazy in making something local remote and refactoring it to be async

Logan Powell17:11:02

that's probably the best way

Logan Powell17:11:11

I'll give that a go

Logan Powell17:11:41

the semantics/contract is just going to be way different

Logan Powell17:11:12

what used to be a value (subordinate) is going to end up being a superordinate

Logan Powell18:11:07

I tried to use an atom and reset! it asynchronously, which worked with those nice semantics not having to change, but it required the function to be called twice to "hydrate" the atom


I think that is maybe the big problem


the values in an atom should be complete


the model for atoms is atomic succession of states, so if you stick in a state that is not complete, then later stick in the completed state, you are departing from that model