Effect CommunityEC
Effect Community2mo ago
4 replies
Mackie

Creating a Pullable Atom from User Input Stream

i'm having trouble with the syntax to make a pullable atom from an Effect<Stream<T>>. atom-react readme shows const countPullAtom = Atom.pull(Stream.make(1, 2, 3, 4, 5)). But what if I want to create a stream from some user input (say "1-10"), which requires user input parsing (Effect that returns a Stream)? is that possible? trying something like this but not 100% sure what i'm doing wrong
const runtime = Atom.runtime(Layer.empty)

const streamAtom = Atom.family((value: string) =>
  runtime.pull(
    Effect.gen(function* () {
      return yield* parseStringIntoNumberStream(value)
    })
  )
)
Was this page helpful?