core-async

samedhi 2019-07-14T00:37:14.283700Z

Is it possible to have a async/chan that will have a side effect run when it is async/close!'d?

samedhi 2019-07-14T00:38:33.284500Z

(regards) Trying to figure out how to implement the following documentation

Returns a channel. If a document exist at `reference`, it will be put! upon
  the channel. If no document exist at reference, then `:firemore/no-document` will
  be put! on the channel. As the document at reference is updated through
  time, the channel will put! the newest value of the document (if it exist)
  or :firemore/no-document (if it does not) upon the channel.

  Important: close! the channel to clean up the state machine feeding this
  channel. Failure to close the channel will result in a memory leak.

samedhi 2019-07-14T00:40:27.286Z

Function could instead return a {:chan c, :unregister fx} to allow for cleanup/closing of channel and state machine, but thought it might be cool to just be able to return a channel and let someone just close! it when they are done with it...

markmarkmark 2019-07-14T01:15:23.287500Z

@samedhi This may be frowned upon, but you could implement a buffer that does the side effect stuff in the buffer's close-buf! method. then pass that buffer to the channel.

samedhi 2019-07-14T01:31:09.287900Z

Very interesting idea. I am going to stick with trying to reason it through with either alt! or mult for now, but I think your solution would work as well. Thank you.

samedhi 2019-07-14T02:15:55.289100Z

https://gist.github.com/samedhi/0e8f5e565877742a5d2649a98b12f715

💯 1
samedhi 2019-07-14T02:17:21.289300Z

>>> Your scientists were so preoccupied with whether or not they could, they didn’t stop to think if they should. - Ian

😅 1