From 6e7f0bba299f9a3f3ae105dfec59b8cfadd1db69 Mon Sep 17 00:00:00 2001 From: Peter Kotula Date: Wed, 11 May 2022 09:14:21 +0200 Subject: [PATCH] zio2 rc6 - readme (#163) --- README.md | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 9293ddb..0f027bd 100644 --- a/README.md +++ b/README.md @@ -111,11 +111,14 @@ This library wraps messages inside of a `zio.akka.cluster.pubsub.MessageEnvelope ```scala import akka.actor.ActorSystem -import zio.{ Managed, Task, ZLayer } +import zio.{ ZIO, ZLayer } import zio.akka.cluster.pubsub.PubSub val actorSystem: ZLayer[Any, Throwable, ActorSystem] = - ZLayer.fromManaged(Managed.acquireReleaseWith(Task(ActorSystem("Test")))(sys => Task.fromFuture(_ => sys.terminate()).either)) + ZLayer + .scoped( + ZIO.acquireRelease(ZIO.attempt(ActorSystem("Test")))(sys => ZIO.fromFuture(_ => sys.terminate()).either) + ) (for { pubSub <- PubSub.createPubSub[String] @@ -176,10 +179,13 @@ This library wraps messages inside of a `zio.akka.cluster.sharding.MessageEnvelo ```scala import akka.actor.ActorSystem import zio.akka.cluster.sharding.{ Entity, Sharding } -import zio.{ Managed, Task, ZIO, ZLayer } +import zio.{ ZIO, ZLayer } val actorSystem: ZLayer[Any, Throwable, ActorSystem] = - ZLayer.fromManaged(Managed.acquireReleaseWith(Task(ActorSystem("Test")))(sys => Task.fromFuture(_ => sys.terminate()).either)) + ZLayer + .scoped( + ZIO.acquireRelease(ZIO.attempt(ActorSystem("Test")))(sys => ZIO.fromFuture(_ => sys.terminate()).either) + ) val behavior: String => ZIO[Entity[Int], Nothing, Unit] = { case "+" => ZIO.serviceWithZIO[Entity[Int]](_.state.update(x => Some(x.getOrElse(0) + 1)))