-
-
Save ashnur/c336b998fbc5d7c7580aa52fe9e827f7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
+ 10 (defhook use-take | |
+ 9 [channel on-take] | |
+ 8 (let [cancel-signal (hooks/use-ref false)] | |
+ 7 (hooks/use-effect | |
+ 6 [channel on-take] | |
+ 5 (go-loop [] | |
+ 4 (if-not @cancel-signal | |
+ 3 (let [msg (<! channel)] | |
+ 2 (if-not (nil? msg) | |
+ 1 (do | |
+ 124 (ontake msg) | |
+ 1 (recur)) | |
+ 2 (reset! cancel-signal true))))) | |
+ 3 #(reset! cancel-signal true)))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment