Effect CommunityEC
Effect Community3y ago
48 replies
bsluther

Using Stream.async to Register Listeners

When the docs say Stream.async "Creates a stream from an asynchronous callback that can be called multiple times", does that mean in the following case my I might register this listener more than once?

const usernameStream = pipe(
    getPublicUser,
    Effect.flatMap(usr => Effect.sync(() =>
      Stream.async<never, never, string>(emit =>
        usr.addListener(data => emit.single(data.username ?? ''))
      )
    ))
  )
Was this page helpful?