Is it possible to have a async/chan
that will have a side effect run when it is async/close!
'd?
(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.
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...
@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.
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.
https://gist.github.com/samedhi/0e8f5e565877742a5d2649a98b12f715
>>> Your scientists were so preoccupied with whether or not they could, they didn’t stop to think if they should. - Ian