Skip to content

Commit

Permalink
zio2 rc6 - readme (#163)
Browse files Browse the repository at this point in the history
  • Loading branch information
justcoon authored May 11, 2022
1 parent 146b343 commit 6e7f0bb
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -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)))
Expand Down

0 comments on commit 6e7f0bb

Please sign in to comment.