-
-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
35 additions
and
35 deletions.
There are no files selected for viewing
35 changes: 35 additions & 0 deletions
35
src/main/scala-3/com/raquo/airstream/split/MatchSplitObservable.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package com.raquo.airstream.split | ||
|
||
import com.raquo.airstream.core.{Observable, BaseObservable} | ||
import scala.annotation.compileTimeOnly | ||
|
||
/** | ||
* `MatchSplitObservable` served as macro's data holder for macro expansion. | ||
* | ||
* For example: | ||
* | ||
* ```scala | ||
* fooSignal.splitMatch | ||
* .handleCase { case Bar(Some(str)) => str } { (str, strSignal) => renderStrNode(str, strSignal) } | ||
* .handleCase { case baz: Baz => baz } { (baz, bazSignal) => renderBazNode(baz, bazSignal) } | ||
* ``` | ||
* | ||
* will be expanded sematically into: | ||
* | ||
* ```scala | ||
* MatchSplitObservable.build(fooSignal, ({ case baz: Baz => baz }) :: ({ case Bar(Some(str)) => str }) :: Nil, handlerMap) | ||
* ``` | ||
*/ | ||
|
||
opaque type MatchSplitObservable[Self[+_] <: Observable[_] , I, O] = Unit | ||
|
||
object MatchSplitObservable { | ||
|
||
@compileTimeOnly("splitMatch without toSignal/toStream is illegal") | ||
def build[Self[+_] <: Observable[_] , I, O]( | ||
observable: BaseObservable[Self, I], | ||
caseList: List[PartialFunction[Any, Any]], | ||
handlerMap: Map[Int, Function[Any, O]] | ||
): MatchSplitObservable[Self, I, O] = throw new UnsupportedOperationException("splitMatch without toSignal/toStream is illegal") | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters