trait WritableSignal[A] extends Signal[A] with WritableObservable[A]
- Alphabetic
- By Inheritance
- WritableSignal
- WritableObservable
- Signal
- SignalSource
- Observable
- BaseObservable
- Named
- Source
- AnyRef
- Any
- Hide All
- Show All
- Public
- Protected
Abstract Value Members
- abstract def currentValueFromParent(): Try[A]
Recalculate the signal's current value.
Recalculate the signal's current value. Typically this asks the parent signal for its current value, and does the math from there, according to the particular signal's logic (e.g. MapSignal would apply the
project
function).This method is used to calculate the signal's initial value, but also to recalculate, this signal's value, to re-sync it with the parent, when this signal is restarted after being stopped. See https://github.com/raquo/Airstream/issues/43
- Attributes
- protected
- Definition Classes
- Signal
- abstract def onWillStart(): Unit
When starting an observable, this is called recursively on every one of its parents that are not started.
When starting an observable, this is called recursively on every one of its parents that are not started. This whole chain happens before onStart callback is called. This chain serves to prepare the internal states of observables that are about to start, e.g. you should update the signal's value to match its parent signal's value in this callback, if applicable.
Default implementation, for observables that don't need anything, should be to call
parent.maybeWillStart()
for every parent observable.If custom behaviour is required, you should generally call
parent.maybeWillStart()
BEFORE your custom logic. Then your logic will be able to make use of parent's updated value.Note: THIS METHOD MUST NOT CREATE TRANSACTIONS OR FIRE ANY EVENTS! DO IT IN ONSTART IF NEEDED.
- Attributes
- protected
- Definition Classes
- BaseObservable
- abstract val topoRank: Int
Note: Use Protected.topoRank(observable) to read another observable's topoRank if needed
Note: Use Protected.topoRank(observable) to read another observable's topoRank if needed
- Attributes
- protected
- Definition Classes
- BaseObservable
Concrete Value Members
- final def !=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def ##: Int
- Definition Classes
- AnyRef → Any
- final def ==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- val _lastUpdateId: Int
- Attributes
- protected[this]
- Definition Classes
- Signal
- def addExternalObserver(observer: Observer[A], owner: Owner): Subscription
Subscribe an external observer to this observable
Subscribe an external observer to this observable
- Attributes
- protected[this]
- Definition Classes
- WritableObservable → BaseObservable
- def addInternalObserver(observer: InternalObserver[A], shouldCallMaybeWillStart: Boolean): Unit
Child observable should call this method on its parents when it is started.
Child observable should call this method on its parents when it is started. This observable calls onStart if this action has given it its first observer (internal or external).
- Attributes
- protected[airstream]
- Definition Classes
- WritableObservable → BaseObservable
- def addObserver(observer: Observer[A])(implicit owner: Owner): Subscription
Subscribe an external observer to this observable
Subscribe an external observer to this observable
- Definition Classes
- WritableObservable → BaseObservable
- final def asInstanceOf[T0]: T0
- Definition Classes
- Any
- def changes: EventStream[A]
A stream of all values in this signal, excluding the initial value.
A stream of all values in this signal, excluding the initial value.
When re-starting this stream, it emits the signal's new current value if and only if something has caused the signal's value to be updated or re-evaluated while the changes stream was stopped. This way the changes stream stays in sync with the signal even after restarting.
- Definition Classes
- Signal
- def clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.CloneNotSupportedException]) @native() @HotSpotIntrinsicCandidate()
- def compose[B](operator: (Signal[A]) => Signal[B]): Signal[B]
- operator
Note: Must not throw!
- Definition Classes
- Signal
- def composeAll[B](changesOperator: (EventStream[A]) => EventStream[B], initialOperator: (Try[A]) => Try[B]): Signal[B]
- changesOperator
Note: Must not throw!
- initialOperator
Note: Must not throw!
- Definition Classes
- Signal
- def composeChanges[AA >: A](operator: (EventStream[A]) => EventStream[AA]): Signal[AA]
- operator
Note: Must not throw!
- Definition Classes
- Signal
- def debugWith(debugger: Debugger[A]): Signal[A]
See also debug methods in com.raquo.airstream.debug.DebuggableObservable
See also debug methods in com.raquo.airstream.debug.DebuggableObservable
- Definition Classes
- Signal → BaseObservable
- def defaultDisplayName: String
This is the method that subclasses override to preserve the user's ability to set custom display names.
This is the method that subclasses override to preserve the user's ability to set custom display names.
- Attributes
- protected
- Definition Classes
- Named
- final def displayName: String
- Definition Classes
- Named
- def distinct: Signal[A]
Distinct events (but keep all errors) by == (equals) comparison
Distinct events (but keep all errors) by == (equals) comparison
- Definition Classes
- BaseObservable
- def distinctBy(key: (A) => Any): Signal[A]
Distinct events (but keep all errors) by matching key Note:
key(event)
might be evaluated more than once for each eventDistinct events (but keep all errors) by matching key Note:
key(event)
might be evaluated more than once for each event- Definition Classes
- BaseObservable
- def distinctByFn(isSame: (A, A) => Boolean): Signal[A]
Distinct events (but keep all errors) using a comparison function
Distinct events (but keep all errors) using a comparison function
- Definition Classes
- BaseObservable
- def distinctByRef(implicit ev: <:<[A, AnyRef]): Signal[A]
Distinct events (but keep all errors) by reference equality (eq)
Distinct events (but keep all errors) by reference equality (eq)
- Definition Classes
- BaseObservable
- def distinctErrors(isSame: (Throwable, Throwable) => Boolean): Signal[A]
Distinct errors only (but keep all events) using a comparison function
Distinct errors only (but keep all events) using a comparison function
- Definition Classes
- BaseObservable
- def distinctTry(isSame: (Try[A], Try[A]) => Boolean): Signal[A]
Distinct all values (both events and errors) using a comparison function
Distinct all values (both events and errors) using a comparison function
- Definition Classes
- Signal → BaseObservable
- final def eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- final def equals(obj: Any): Boolean
Airstream may internally use Scala library functions which use
==
orhashCode
for equality, for example List.contains.Airstream may internally use Scala library functions which use
==
orhashCode
for equality, for example List.contains. Comparing observables by structural equality pretty much never makes sense, yet it's not that hard to run into that, all you need is to create acase class
subclass, and the Scala compiler will generate a structural-equalityequals
andhashCode
methods for you behind the scenes.To prevent that, we make equals and hashCode methods final, using the default implementation (which is reference equality).
- Definition Classes
- BaseObservable → AnyRef → Any
- val externalObservers: ObserverList[Observer[A]]
Note: Observer can be added more than once to an Observable.
Note: Observer can be added more than once to an Observable. If so, it will observe each event as many times as it was added.
- Attributes
- protected
- Definition Classes
- WritableObservable
- final def fireError(nextError: Throwable, transaction: Transaction): Unit
- Attributes
- protected
- Definition Classes
- WritableSignal → WritableObservable
- def fireTry(nextValue: Try[A], transaction: Transaction): Unit
Signal propagates only if its value has changed
Signal propagates only if its value has changed
- Attributes
- protected
- Definition Classes
- WritableSignal → WritableObservable
- final def fireValue(nextValue: A, transaction: Transaction): Unit
- Attributes
- protected
- Definition Classes
- WritableSignal → WritableObservable
- def flatMap[B, Inner[_], Output[+_] <: Observable[_]](compose: (A) => Inner[B])(implicit strategy: FlattenStrategy[[+_]Signal[_], Inner, Output]): Output[B]
- compose
Note: guarded against exceptions
- Definition Classes
- BaseObservable
- Annotations
- @inline()
- def foreach(onNext: (A) => Unit)(implicit owner: Owner): Subscription
Create an external observer from a function and subscribe it to this observable.
Create an external observer from a function and subscribe it to this observable.
Note: since you won't have a reference to the observer, you will need to call Subscription.kill() to unsubscribe
- Definition Classes
- BaseObservable
- final def getClass(): Class[_ <: AnyRef]
- Definition Classes
- AnyRef → Any
- Annotations
- @native() @HotSpotIntrinsicCandidate()
- def getOrCreatePendingObserverRemovals: JsArray[() => Unit]
- Attributes
- protected
- Definition Classes
- BaseObservable
- final def hashCode(): Int
Force reference equality checks.
Force reference equality checks. See comment for
equals
.- Definition Classes
- BaseObservable → AnyRef → Any
- val internalObservers: ObserverList[InternalObserver[A]]
Note: This is enforced to be a Set outside of the type system #performance
Note: This is enforced to be a Set outside of the type system #performance
- Attributes
- protected
- Definition Classes
- WritableObservable
- final def isInstanceOf[T0]: Boolean
- Definition Classes
- Any
- val isSafeToRemoveObserver: Boolean
- Attributes
- protected
- Definition Classes
- BaseObservable
- def isStarted: Boolean
- Attributes
- protected
- Definition Classes
- BaseObservable
- def lastUpdateId: Int
- def map[B](project: (A) => B): Signal[B]
- project
Note: guarded against exceptions
- Definition Classes
- Signal → BaseObservable
- def mapTo[B](value: => B): Signal[B]
value
is passed by name, so it will be evaluated whenever the Observable fires.value
is passed by name, so it will be evaluated whenever the Observable fires. Use it to sample mutable values (e.g. myInput.ref.value in Laminar).See also: mapToStrict
- value
Note: guarded against exceptions
- Definition Classes
- BaseObservable
- def mapToStrict[B](value: B): Signal[B]
value
is evaluated strictly, only once, when this method is called.value
is evaluated strictly, only once, when this method is called.See also: mapTo
- Definition Classes
- BaseObservable
- def mapToUnit: Signal[Unit]
- Definition Classes
- BaseObservable
- def matchStreamOrSignal[B](ifStream: (EventStream[A]) => B, ifSignal: (Signal[A]) => B): B
- Definition Classes
- BaseObservable
- val maybeDisplayName: UndefOr[String]
This name should identify the instance (observable or observer) uniquely enough for your purposes.
This name should identify the instance (observable or observer) uniquely enough for your purposes. You can read / write it to simplify debugging. Airstream uses this in
debugLog*
methods. In the future, we will expand on this. #TODO[Debug] We don't use this to its full potential yet.- Attributes
- protected[this]
- Definition Classes
- Named
- val maybeLastSeenCurrentValue: UndefOr[Try[A]]
- Attributes
- protected
- val maybePendingObserverRemovals: UndefOr[JsArray[() => Unit]]
Observer removals scheduled to run as soon as this observable's event propagation finishes.
Observer removals scheduled to run as soon as this observable's event propagation finishes. Only put calls to
removeInternalObserverNow
andremoveExternalObserverNow
here, no custom logic.- Attributes
- protected
- Definition Classes
- BaseObservable
- def maybeWillStart(): Unit
- Attributes
- protected
- Definition Classes
- BaseObservable
- final def ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- final def notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native() @HotSpotIntrinsicCandidate()
- final def notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native() @HotSpotIntrinsicCandidate()
- def now(): A
Get the signal's current value
- def numAllObservers: Int
Total number of internal and external observers
Total number of internal and external observers
- Attributes
- protected
- Definition Classes
- WritableObservable → BaseObservable
- def observe(implicit owner: Owner): OwnedSignal[A]
Add a noop observer to this signal to ensure that it's started.
Add a noop observer to this signal to ensure that it's started. This lets you access .now and .tryNow on the resulting StrictSignal.
You can use
myStream.toWeakSignal.observe.tryNow()
to read the last emitted value from event streams just as well.- Definition Classes
- Signal
- def onAddedExternalObserver(observer: Observer[A]): Unit
- Attributes
- protected
- Definition Classes
- Signal → BaseObservable
- def onStart(): Unit
Here we need to ensure that Signal's default value has been evaluated at least once.
Here we need to ensure that Signal's default value has been evaluated at least once. It is important because if a Signal gets started by means of its .changes stream acquiring an observer, nothing else would trigger this evaluation because initialValue is not directly used by the .changes stream. However, when the events start coming in, we will need this initialValue because Signal needs to know when its current value has changed.
- Attributes
- protected[this]
- Definition Classes
- Signal → BaseObservable
- def onStop(): Unit
This method is fired when this observable stops working (listening for parent events and/or firing its own events), that is, when it loses its last Observer (internal or external).
This method is fired when this observable stops working (listening for parent events and/or firing its own events), that is, when it loses its last Observer (internal or external).
onStop can potentially be called multiple times, the second time being after it has started again (see onStart).
- Attributes
- protected
- Definition Classes
- BaseObservable
- implicit def protectedAccessEvidence: Protected
- Attributes
- protected
- Definition Classes
- BaseObservable
- Annotations
- @inline()
- def recover[B >: A](pf: PartialFunction[Throwable, Option[B]]): Signal[B]
- pf
Note: guarded against exceptions
- Definition Classes
- Signal → BaseObservable
- def recoverIgnoreErrors: Signal[A]
- Definition Classes
- BaseObservable
- def recoverToTry: Signal[Try[A]]
Convert this to an observable that emits Failure(err) instead of erroring
Convert this to an observable that emits Failure(err) instead of erroring
- Definition Classes
- Signal → BaseObservable
- def removeExternalObserver(observer: Observer[A]): Unit
Note: do not expose this to end users.
Note: do not expose this to end users. See https://github.com/raquo/Airstream/issues/10
Removal still happens synchronously, just after we're done iterating over this observable's observers, to avoid interference with that logic.
Note: The delay is necessary not just because of interference with actual while(index < observers.length) iteration, but also because on a high level it is too risky to remove observers from arbitrary observables while the propagation is running. This would mean that some graphs would not propagate fully, which would break very basic expectations of end users.
UPDATE: In 15.0.0 we made the observable removal delay more fine grained – previously we would wait until the whole transaction completed before removing observers, now we only wait until this observable's iteration is done. This helped us fix https://github.com/raquo/Airstream/issues/95
Note: To completely unsubscribe an Observer from this Observable, you need to remove it as many times as you added it to this Observable.
- Attributes
- protected[airstream]
- Definition Classes
- BaseObservable
- def removeExternalObserverNow(observer: Observer[A]): Unit
- Attributes
- protected[airstream]
- Definition Classes
- WritableObservable → BaseObservable
- def removeInternalObserver(observer: InternalObserver[A]): Unit
Safely remove internal observer (such that it doesn't interfere with iteration over the list of observers).
Safely remove internal observer (such that it doesn't interfere with iteration over the list of observers). Removal still happens synchronously, just after we're done iterating over this observable's observers.
Child observable should call this method on its parents when it is stopped.
- Attributes
- protected[airstream]
- Definition Classes
- BaseObservable
- def removeInternalObserverNow(observer: InternalObserver[A]): Unit
Child observable should call parent.removeInternalObserver(childInternalObserver) when it is stopped.
Child observable should call parent.removeInternalObserver(childInternalObserver) when it is stopped. This observable calls onStop if this action has removed its last observer (internal or external).
- Attributes
- protected[airstream]
- Definition Classes
- WritableObservable → BaseObservable
- def scanLeft[B](makeInitial: (A) => B)(fn: (B, A) => B): Signal[B]
A signal that emits the accumulated value every time that the parent signal emits.
A signal that emits the accumulated value every time that the parent signal emits.
- makeInitial
Note: guarded against exceptions
- fn
Note: guarded against exceptions
- Definition Classes
- Signal
- def scanLeftRecover[B](makeInitial: (Try[A]) => Try[B])(fn: (Try[B], Try[A]) => Try[B]): Signal[B]
A signal that emits the accumulated value every time that the parent signal emits.
A signal that emits the accumulated value every time that the parent signal emits.
- makeInitial
currentParentValue => initialValue Note: must not throw
- fn
(currentValue, nextParentValue) => nextValue
- Definition Classes
- Signal
- def setCurrentValue(newValue: Try[A], isInitial: Boolean = false): Unit
- Attributes
- protected
- def setDisplayName(name: String): WritableSignal.this.type
Set the display name for this instance (observable or observer).
Set the display name for this instance (observable or observer). - This method modifies the instance and returns
this
. It does not create a new instance. - New name you set will override the previous name, if any. This might change in the future. For the sake of sanity, don't call this more than once for the same instance. - If display name is set, toString will output it instead of the standard type@hashcode string- Definition Classes
- Named
- final def synchronized[T0](arg0: => T0): T0
- Definition Classes
- AnyRef
- def throwFailure[B](implicit ev: <:<[A, Try[B]]): Signal[B]
Unwrap Try to "undo"
recoverToTry
– Encode Failure(err) as observable errors, and Success(v) as eventsUnwrap Try to "undo"
recoverToTry
– Encode Failure(err) as observable errors, and Success(v) as events- Definition Classes
- BaseObservable
- def toObservable: Signal[A]
- Definition Classes
- Signal → SignalSource → Source
- def toSignalIfStream[B >: A](ifStream: (EventStream[A]) => Signal[B]): Signal[B]
- Definition Classes
- BaseObservable
- def toStreamIfSignal[B >: A](ifSignal: (Signal[A]) => EventStream[B]): EventStream[B]
- Definition Classes
- BaseObservable
- final def toString(): String
Override defaultDisplayName instead of this, if you need to.
Override defaultDisplayName instead of this, if you need to.
- Definition Classes
- Named → AnyRef → Any
- def toWeakSignal: Signal[Option[A]]
Convert this observable to a signal of Option[A].
Convert this observable to a signal of Option[A]. If it is a stream, set initial value to None.
- Definition Classes
- BaseObservable
- def tryNow(): Try[A]
Note: Initial value is only evaluated if/when needed (when there are observers)
Note: Initial value is only evaluated if/when needed (when there are observers)
- Attributes
- protected[airstream]
- Definition Classes
- WritableSignal → Signal
- final def wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException]) @native()
- final def wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
Deprecated Value Members
- def finalize(): Unit
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.Throwable]) @Deprecated
- Deprecated
- def foldLeft[B](makeInitial: (A) => B)(fn: (B, A) => B): Signal[B]
- Definition Classes
- Signal
- Annotations
- @deprecated
- Deprecated
(Since version 15.0.0-M1) foldLeft was renamed to scanLeft
- def foldLeftRecover[B](makeInitial: (Try[A]) => Try[B])(fn: (Try[B], Try[A]) => Try[B]): Signal[B]
- Definition Classes
- Signal
- Annotations
- @deprecated
- Deprecated
(Since version 15.0.0-M1) foldLeftRecover was renamed to scanLeftRecover