Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Signal<A>

Signal is a lightweight FRP-like Monad heavily inspired by the Elm Signal implementation. It was ported from an original PureScript implementation created by Bodil Stokke.

This class provides tools to manipulate values that a Signal receives, allowing you to apply transforms to each value sent to the Signal. To get started, however, you'll want to use the Channel or the (upcoming) Loop classes to set up a new signal for usage.

Type parameters

  • A

    The Type of value the Signal yields

Hierarchy

  • Signal

Implements

Index

Methods

apply

  • Apply a function stored in another Signal to the value stored in this Signal.

    Type parameters

    • B

    Parameters

    Returns Signal<B>

delay

  • delay(time: number): Signal<A>
  • Takes a signal and delays its yielded values by a given number of milliseconds.

    Parameters

    • time: number

    Returns Signal<A>

dropRepeats

  • Create a signal which only yields values which aren't equal to the previous value of the input signal.

    Returns Signal<A>

filter

  • filter(func: function, a: A): Signal<A>
  • Takes a signal and filters out yielded values for which the provided predicate function returns false.

    Parameters

    • func: function
        • (a: A): boolean
        • Parameters

          • a: A

          Returns boolean

    • a: A

    Returns Signal<A>

flatten

  • Turn a signal of collections of items into a signal of each item inside each collection, in order.

    Type parameters

    • B

    Parameters

    • b: B

    Returns Signal<B>

foldp

  • foldp<B>(func: function, seed: B): Signal<B>
  • Creates a past dependent signal. The function argument takes the value of the input signal, and the previous value of the output signal, to produce the new value of the output signal.

    Type parameters

    • B

    Parameters

    • func: function
        • (a: A): function
        • Parameters

          • a: A

          Returns function

            • (b: B): B
            • Parameters

              • b: B

              Returns B

    • seed: B

    Returns Signal<B>

map

  • map<B>(func: function): Signal<B>
  • Apply a function to the Signal's value.

    Type parameters

    • B

    Parameters

    • func: function
        • (a: A): B
        • Parameters

          • a: A

          Returns B

    Returns Signal<B>

merge

  • Merge two signals, returning a new signal which will yield a value whenever either of the input signals yield. Its initial value will be that of the first signal.

    Parameters

    Returns Signal<A>

on

  • on(func: function): Signal<A>
  • Runs side effects over the values of a Signal.

    Parameters

    • func: function
        • (a: A): void
        • Parameters

          • a: A

          Returns void

    Returns Signal<A>

sampleOn

  • Creates a signal which yields the current value of the second signal every time the first signal yields.

    Type parameters

    • B

    Parameters

    Returns Signal<B>

since

  • since(time: number): Signal<boolean>
  • Takes a signal and a time value, and creates a signal which yields True when the input signal yields, then goes back to False after the given number of milliseconds have elapsed, unless the input signal yields again in the interim.

    Parameters

    • time: number

    Returns Signal<boolean>

then

  • then<B>(func: function): Signal<B>
  • Bind a new operation to the Signal, transforming the value.

    Type parameters

    • B

    Parameters

    • func: function

    Returns Signal<B>

Static constant

  • constant<A>(value: A): Signal<A>
  • Create a signal with a constant value.

    Type parameters

    • A

    Parameters

    • value: A

    Returns Signal<A>

Static every

  • Creates a signal which yields the current time (according to now) every given number of milliseconds.

    Parameters

    • interval: number

    Returns Signal<Time>

Static run

  • Given a Signal of effects with no return value, run each effect as it comes in.

    Type parameters

    • A: Function

    Parameters

    Returns void

Static unwrap

  • Takes a signal of effects of a, and produces an effect which returns a signal which will take each effect produced by the input signal, run it, and yield its returned value.

    Type parameters

    • A: Function

    Parameters

    Returns Signal<A>

Generated using TypeDoc