-
-
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.
API: Implicits to automatically enable split macro syntax
- Loading branch information
Showing
6 changed files
with
32 additions
and
25 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
6 changes: 6 additions & 0 deletions
6
src/main/scala-2.13/com/raquo/airstream/core/ObservableMacroImplicits.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,6 @@ | ||
package com.raquo.airstream.core | ||
|
||
trait ObservableMacroImplicits { | ||
// Airstream's macro features are not implemented for Scala 2. | ||
// See same-named file in `scala-3` directory. | ||
} |
22 changes: 22 additions & 0 deletions
22
src/main/scala-3/com/raquo/airstream/core/ObservableMacroImplicits.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,22 @@ | ||
package com.raquo.airstream.core | ||
|
||
import com.raquo.airstream.core.{Observable, BaseObservable, Signal} | ||
import com.raquo.airstream.split.{DuplicateKeysConfig, SplitMatchOneObservable, SplitMatchSeqObservable} | ||
|
||
trait ObservableMacroImplicits { | ||
|
||
extension [Self[+_] <: Observable[_], I](inline observable: BaseObservable[Self, I]) { | ||
inline def splitMatchOne: SplitMatchOneObservable[Self, I, Nothing] = | ||
SplitMatchOneObservable.build(observable)()() | ||
} | ||
|
||
extension [Self[+_] <: Observable[_], I, K, CC[_]](inline observable: BaseObservable[Self, CC[I]]) { | ||
inline def splitMatchSeq( | ||
inline keyFn: Function1[I, K], | ||
inline distinctCompose: Function1[Signal[I], Signal[I]] = (iSignal: Signal[I]) => iSignal.distinct, | ||
inline duplicateKeysConfig: DuplicateKeysConfig = DuplicateKeysConfig.default, | ||
) = { | ||
SplitMatchSeqObservable.build(keyFn, distinctCompose, duplicateKeysConfig, observable)()() | ||
} | ||
} | ||
} |
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
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
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