-
-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
API: Re-evaluate signal's current value when restarting signal
- This is a big change to fix #43 - Not quite complete yet, still need to work on various timing streams - Also removed some Future-related stuff that I don't want to support anymore
- Loading branch information
Showing
73 changed files
with
2,061 additions
and
772 deletions.
There are no files selected for viewing
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
12 changes: 6 additions & 6 deletions
12
src/main/scala/com/raquo/airstream/combine/CombineSignalN.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
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
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
14 changes: 14 additions & 0 deletions
14
src/main/scala/com/raquo/airstream/common/MultiParentEventStream.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,14 @@ | ||
package com.raquo.airstream.common | ||
|
||
import com.raquo.airstream.core.{Observable, Protected, WritableEventStream} | ||
|
||
/** A simple stream that has multiple parents. */ | ||
trait MultiParentEventStream[+I, O] extends WritableEventStream[O] { | ||
|
||
protected[this] val parents: Seq[Observable[I]] | ||
|
||
override protected def onWillStart(): Unit = { | ||
parents.foreach(Protected.maybeWillStart) | ||
} | ||
|
||
} |
23 changes: 23 additions & 0 deletions
23
src/main/scala/com/raquo/airstream/common/MultiParentSignal.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,23 @@ | ||
package com.raquo.airstream.common | ||
|
||
import com.raquo.airstream.core.{Observable, Protected, WritableSignal} | ||
|
||
import scala.util.Try | ||
|
||
/** A simple signal that has multiple parents. */ | ||
trait MultiParentSignal[+I, O] extends WritableSignal[O] { | ||
|
||
protected[this] val parents: Seq[Observable[I]] | ||
|
||
override protected def onWillStart(): Unit = { | ||
parents.foreach(Protected.maybeWillStart) | ||
updateCurrentValueFromParent() | ||
} | ||
|
||
protected def updateCurrentValueFromParent(): Try[O] = { | ||
val nextValue = currentValueFromParent() | ||
setCurrentValue(nextValue) | ||
nextValue | ||
} | ||
|
||
} |
25 changes: 25 additions & 0 deletions
25
src/main/scala/com/raquo/airstream/common/SingleParentEventStream.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,25 @@ | ||
package com.raquo.airstream.common | ||
|
||
import com.raquo.airstream.core.{InternalObserver, Observable, Protected, Transaction, WritableEventStream} | ||
|
||
/** A simple stream that only has one parent. */ | ||
trait SingleParentEventStream[I, O] extends WritableEventStream[O] with InternalObserver[I] { | ||
|
||
protected[this] val parent: Observable[I] | ||
|
||
override protected def onWillStart(): Unit = { | ||
//println(s"${this} >>>> onWillStart") | ||
Protected.maybeWillStart(parent) | ||
} | ||
|
||
override protected[this] def onStart(): Unit = { | ||
//println(s"${this} >>>> onStart") | ||
parent.addInternalObserver(this, shouldCallMaybeWillStart = false) | ||
super.onStart() | ||
} | ||
|
||
override protected[this] def onStop(): Unit = { | ||
Transaction.removeInternalObserver(parent, observer = this) | ||
super.onStop() | ||
} | ||
} |
19 changes: 0 additions & 19 deletions
19
src/main/scala/com/raquo/airstream/common/SingleParentObservable.scala
This file was deleted.
Oops, something went wrong.
39 changes: 39 additions & 0 deletions
39
src/main/scala/com/raquo/airstream/common/SingleParentSignal.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,39 @@ | ||
package com.raquo.airstream.common | ||
|
||
import com.raquo.airstream.core.{InternalObserver, Observable, Protected, Transaction, WritableSignal} | ||
|
||
import scala.util.Try | ||
|
||
/** A simple stream that only has one parent. */ | ||
trait SingleParentSignal[I, O] extends WritableSignal[O] with InternalObserver[I] { | ||
|
||
protected[this] val parent: Observable[I] | ||
|
||
override protected def onWillStart(): Unit = { | ||
//println(s"${this} >>>> onWillStart") | ||
Protected.maybeWillStart(parent) | ||
updateCurrentValueFromParent() | ||
} | ||
|
||
/** Note: this is overridden in: | ||
* - [[com.raquo.airstream.distinct.DistinctSignal]] | ||
* - [[com.raquo.airstream.flatten.SwitchSignal]] | ||
*/ | ||
protected def updateCurrentValueFromParent(): Try[O] = { | ||
//println(s"${this} >> updateCurrentValueFromParent") | ||
val nextValue = currentValueFromParent() | ||
setCurrentValue(nextValue) | ||
//println(s"${this} << updateCurrentValueFromParent") | ||
nextValue | ||
} | ||
|
||
override protected[this] def onStart(): Unit = { | ||
parent.addInternalObserver(this, shouldCallMaybeWillStart = false) | ||
super.onStart() | ||
} | ||
|
||
override protected[this] def onStop(): Unit = { | ||
Transaction.removeInternalObserver(parent, observer = this) | ||
super.onStop() | ||
} | ||
} |
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
Oops, something went wrong.