ScalarSignal

Properties

PropertyDescription

lastValue

(get) lastValue: number (set) (Not Available)

Specifies a number that represents the last value of the signal.

Note: The signal value is updated during simulation tick. This means that the value of lastValue is undefined before its first update. It is also undefined for signals that aren't used for any bindings/subscriptions, because those signals aren't guaranteed to be updated at each simulation tick.

Methods

MethodDescription

abs

abs(): ScalarSignal

Returns a signal with the value that is the absolute value of the given signal.

See Also: ReactiveModule.abs

add

add(other: ScalarSignal): ScalarSignal

Returns a signal with the value that is the sum of the values of the given signals.

Note: add and sum functions are synonims, the behavior they provide is equivalent.

See Also: ScalarSignal.sum, ReactiveModule.add`

atan2

atan2(other: ScalarSignal): ScalarSignal

Returns a signal with the value that is the angle in radians between the x-axis and the ray from (0, 0) to (x, y) where x and y are the values of the specified signals. The range is -PI to +PI.

See Also: ReactiveModule.atan2

ceil

ceil(): ScalarSignal

Returns a signal with the value that is the smallest integer that is greater than or equal to the value of the given signal.

See Also: ReactiveModule.ceil

delayBy

delayBy({milliseconds: number}): ScalarSignal

Delays a variable signal. The argument is an object with a "milliseconds" property specifying the delay duration in milliseconds.

div

div(other: ScalarSignal): ScalarSignal

Returns a signal with the value that is the value of the first signal divided by the value of the second signal.

See Also: ReactiveModule.div

eq

eq(other: ScalarSignal): BoolSignal

Returns a Boolean signal that takes the value of true every time when the value of the left-hand-side signal is equal to the value of the right-hand-side one, and the value of false all other time.

Note: the scalar values are tested for exact equality. For some applications it might be reasonable to perform a non-strict comparison allowing the values to be within a small distance one from another.

See Also: ReactiveModule.eq

expSmooth

expSmooth(dampFactor: number): ScalarSignal

Smoothes a variable signal using exponential averaging over time. The argument specifies the dampening time constant in milliseconds.

Note: See also ReactiveModule.expSmooth.

floor

floor(): ScalarSignal

Returns a signal with the value that is the largest integer that is less than or equal to the value of the given signal.

See Also: ReactiveModule.floor

format

format(formatString: string): StringSignal

Converts a ScalarSignal to a StringSignal according to the supplied formatting string.

Note: formatString shall conform to the Folly formatting rules as specified here: https://github.com/facebook/folly/blob/master/folly/docs/Format.md#format-string-syntax .

See Also: ScalarSignal.toString.

ge

ge(other: ScalarSignal): BoolSignal

Returns a Boolean signal that takes the value of true every time when the value of the left-hand-side signal is greater than or equal to the value of the right-hand-side one, and the value of false all other time.

See Also: ReactiveModule.ge

gt

gt(other: ScalarSignal): BoolSignal

Returns a Boolean signal that takes the value of true every time when the value of the left-hand-side signal is strictly greater than the value of the right-hand-side one, and the value of false all other time.

See Also: ReactiveModule.gt

interval

interval(threshold: number): EventSource

Returns an EventSource that emits an event whenever the supplied ScalarSignal first passes (becomes greater than or equal) a value of N*threshold, N = 1, 2, 3, ... Events are signaled in increasing order of N, starting from 1, with no omissions. For each value of N, the respective event is fired only once.

The emitted event (the argument passed to the callback function) has the value of corresponding N*threshold.

Note: The threshold must be a positive number.

Note: interval is mostly useful for non-negative non-decreasing scalar signals.

See Also: ReactiveModule.trigger, ReactiveModule.multiTrigger.

le

le(other: ScalarSignal): BoolSignal

Returns a Boolean signal that takes the value of true every time when the value of the left-hand-side signal is less than or equal to the value of the right-hand-side one, and the value of false all other time.

See Also: ReactiveModule.le

lt

lt(other: ScalarSignal): BoolSignal

Returns a Boolean signal that takes the value of true every time when the value of the left-hand-side signal is strictly less than the value of the right-hand-side one, and the value of false all other time.

See Also: ReactiveModule.lt

mod

mod(other: ScalarSignal): ScalarSignal

Returns a signal with the value that is the floating-point remainder of the division of the value of the first signal by the value of the second signal.

See Also: ReactiveModule.mod

monitor

monitor(): EventSource monitor(config: { fireOnInitialValue: ?boolean}): EventSource

Returns an EventSource that emits an event every time the value of the input signal changes. The event contains a JSON object with the old and new values in the format:

{ "oldValue": val, "newValue": val }

Note: By default, there is no event fired for the initial value of the signal. If config.fireOnInitialValue is set to true then an event for initial signal value is also emitted. oldValue is unset for this initial event.

mul

mul(other: ScalarSignal): ScalarSignal mul(other: VectorSignal): VectorSignal

Returns a signal with the value that is the product of the values of the given signals.

See Also: ReactiveModule.mul, VectorSignal.mul

multiTrigger

multiTrigger(threshold: number): EventSource

Returns an EventSource that fires every time the signal raises to (becomes greater than or equal after being less than) the value of threshold.

The emitted event (the argument passed to the callback function) has the value of threshold.

Note: The initial value of the signal is assumed to be 0.0.

See Also: ReactiveModule.trigger, ReactiveModule.interval.

ne

ne(other: ScalarSignal): BoolSignal

Returns a Boolean signal that takes the value of true every time when the value of the left-hand-side signal is not equal to the value of the right-hand-side one, and the value of false all other time.

Note: the scalar values are tested for exact equality. For some applications it might be reasonable to perform a non-strict comparison allowing the values to be within a small distance one from another.

See Also: ReactiveModule.ne

neg

neg(): ScalarSignal

Returns a signal with the negated value of the given signal.

See Also: ReactiveModule.neg, VectorSignal.neg

pin

pin(): ScalarSignal

Returns a ScalarSignal containing a constant value which is the value of the specified signal immediately after pin is called.

pow

pow(exponent: ScalarSignal): ScalarSignal

Returns a signal with the value that is the base signal raised to the power of the exponent signal.

Raising a negative base to the power of a fractional exponent produce a NaN. Raising 0 to the power of a negative exponent will produce positive infinity. Raising 0 to the power of any positive exponent will produce 0. Raising -1 to the power of a positive or negative infinity exponent will produce 1. Raising 1 to the power of any exponent, including NaN, will produce 1. Raising any base, including NaN, to the power of 0 will produce 1. Raising any base to the power of negative infinity, where |base| < 1, will produce positive infinity. Raising any base to the power of negative infinity, where |base| > 1, will produce 0. Raising any base to the power of positive infinity, where |base| < 1, will produce 0. Raising any base to the power of positive infinity, where |base| > 1, will produce positive infinity. Raising negative infinity to the power of a negative exponent will produce 0. Raising negative infinity to the power of a positive exponent will produce positive infinity. Raising positive infinity to the power of a negative exponent will produce 0. Raising positive infinity to the power of a positive exponent will produce positive infinity.

In all other cases, if either the base or the exponent is a NaN, a NaN will be produced.

See Also: ReactiveModule.pow

round

round(): ScalarSignal

Returns a signal with the value that is the rounded value of the given signal.

Note: When the fractional part is 0.5, it rounds the number away from zero, which is at odds with JavaScript standard behavior of rounding it always up in such cases. Therefore, this function is NOT exactly the reactive counterpart of the standard JavaScript Math.round utility.

See Also: ReactiveModule.round

schmittTrigger

schmittTrigger(config: { low: number, high: number, initialValue: ?boolean}): BoolSignal

Returns a Boolean signal that is true when the input is strictly greater than the upper threshold, and false when it is strictly less than the lower threshold. For input values between and including the thresholds, the Shmitt trigger returns the same value as at the previous update, or initialValue if this is the first update.

Note: The initialValue is assumed to be false if it isn't specified.

sign

sign(): ScalarSignal

Returns a signal with the value that is the sign of the given signal. Possible sign values: NaN, -0.0, 0.0, -1.0, 1.0.

Note: this function is the reactive counterpart of the standard JavaScript Math.sign utility.

See Also: ReactiveModule.sign

sqrt

sqrt(): ScalarSignal

Returns a signal with the value that is the square root of the value of the given signal.

See Also: ReactiveModule.sqrt

sub

sub(other: ScalarSignal): ScalarSignal

Returns a signal with the value that is the difference of the values of the given signals.

See Also: ReactiveModule.sub, VectorSignal.sub, PointSignal.sub

sum

sum(other: ScalarSignal): ScalarSignal

Returns a signal with the value that is the sum of the values of the given signals.

Note: add and sum functions are synonims, the behavior they provide is equivalent.

See Also: ScalarSignal.add, ReactiveModule.sum

toString

toString(): StringSignal

Converts a ScalarSignal to a StringSignal according to the default string formatting rules.

Note: ScalarSignal.format allows more flexible control over the way the number is converted to string.

trigger

trigger(threshold: number): EventSource

Returns an EventSource that fires the first time the value of the signal raises (becomes greater than or equal) to the level of threshold. No more than one event is ever emitted by this EventSource.

The emitted event (the argument passed to the callback function) has the value of threshold.

Note: for positive thresholds, trigger is equivalent to interval(threshold).take(1).

See Also: ReactiveModule.multiTrigger, ReactiveModule.interval.