Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EmitterBuilder to create IO[R] #195

Closed
cornerman opened this issue May 12, 2018 · 0 comments · Fixed by #210
Closed

EmitterBuilder to create IO[R] #195

cornerman opened this issue May 12, 2018 · 0 comments · Fixed by #210

Comments

@cornerman
Copy link
Member

cornerman commented May 12, 2018

I was just trying to create a custom EmitterBuilder for some modifier combiniation, but was not able to model this properly. When creating a SimpleEmitterBuilder[E,R], I can provide a create function Observer[E] => R, whose result is then wrapped with IO.pure.

In this case, I want to return an IO[R], which does not work as expected

  def valueOnEnter: SimpleEmitterBuilder[String, VDomModifier] = SimpleEmitterBuilder { (observer: Observer[String]) =>
    for {
      userInput <- Handler.create[String]
      actionSink = ObserverSink(observer)
      modifiers <- Seq(
        managed(actionSink <-- userInput),
        ...
        onKeyDown.value --> actionSink
      )
    } yield modifiers
  }

Now def -->(sink: Sink[_ >: E]): IO[R] = IO.pure(create(sink.observer)) will yield an IO[IO[Modifier]], which is not really usable.

Any ideas how to use this? Or should we make a version with IO[R]?

Additionally, having a Sink instead of an observer would be preferable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant