Created
May 15, 2022 22:03
-
-
Save chenharryhua/45daa489bd856ff3c3e27492be48f1e2 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
import fs2.Stream | |
val r1 = Stream.resource(Resource.make(IO.println("acquire 1"))(_ => IO.println("release 1"))) | |
val r2 = Stream.bracket(IO.println("acquire 2"))(_ => IO.println("release 2")) | |
val ss = | |
r1.onFinalizeWeak(IO.println("final 1")) | |
.flatMap(_ => r2.onFinalize(IO.println("final 2"))).evalMap(_ => IO.println("do work")) | |
++ fs2.Stream.eval(IO.println("----")) ++ fs2.Stream.sleep[IO](2.second) | |
ss.compile.drain.unsafeRunSync() |
Author
chenharryhua
commented
May 15, 2022
•
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment