Skip to content
This repository was archived by the owner on Sep 10, 2024. It is now read-only.
This repository was archived by the owner on Sep 10, 2024. It is now read-only.

unzip and uneither #59

@ziggystar

Description

@ziggystar

For my own project, I had to implement those two methods. I did it on EventStream by the code below. I'm very new to reactive and don't know where to put it in the library, otherwise I would file a pull request.

  implicit def eventStreamRich[T](es: EventStream[T]) = new {

    def unzip[A,B](implicit ev: T <:< (A,B)): (EventStream[A],EventStream[B]) =
      (es.map(t => ev(t)._1), es.map(t => ev(t)._2))

    def uneither[A,B](implicit ev: T <:< Either[A,B]): (EventStream[A],EventStream[B]) = (
        es.collect{case t if(ev(t).isLeft) => ev(t).left.get},
        es.collect{case t if(ev(t).isRight) => ev(t).right.get}
      )

  }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions