Options
All
  • Public
  • Public/Protected
  • All
Menu

External module "Behavior"

Index

Type aliases

Time

Time: number

Variables

time

time: Behavior<Time> = fromFunction(Date.now)

A behavior whose value is the number of milliseconds elapsed win UNIX epoch. I.e. its current value is equal to the value got by calling Date.now.

timeFrom

timeFrom: Behavior<Behavior<Time>> = fromFunction(() => new TimeFromBehavior())

A behavior giving access to continous time. When sampled the outer behavior gives a behavior with values that contain the difference between the current sample time and the time at which the outer behavior was sampled.

Functions

ap

  • Apply a function valued behavior to a value behavior.

    Type parameters

    • A

    • B

    Parameters

    • fnB: Behavior<function>

      behavior of functions from A to B

    • valB: Behavior<A>

      A behavior of A

    Returns Behavior<B>

    Behavior of the function in fnB applied to the value in valB

at

fromFunction

  • fromFunction<B>(fn: function): Behavior<B>
  • This takes an impure function that varies over time and returns a pull-driven behavior. This is particulairly useful if the function is contionusly changing, like Date.now.

    Type parameters

    • B

    Parameters

    • fn: function
        • (): B
        • Returns B

    Returns Behavior<B>

isBehavior

  • isBehavior(b: any): boolean

map

  • Map a function over a behavior. This means that if at some point in time the value of b is bVal then the value of the returned behavior is fn(bVal).

    Type parameters

    • A

    • B

    Parameters

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

          • a: A

          Returns B

    • b: Behavior<A>

    Returns Behavior<B>

observe

  • observe<A>(push: function, beginPulling: function, endPulling: function, b: Behavior<A>): CbObserver<A>
  • Observe a behavior for the purpose of executing imperative actions based on the value of the behavior.

    Type parameters

    • A

    Parameters

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

          • a: A

          Returns void

    • beginPulling: function
        • (): void
        • Returns void

    • endPulling: function
        • (): void
        • Returns void

    • b: Behavior<A>

    Returns CbObserver<A>

of

placeholder

publish

  • publish<A>(a: A, b: Behavior<A>): void
  • Imperatively push a value into a behavior.

    Type parameters

    • A

    Parameters

    Returns void

scan

  • The returned behavior initially has the initial value, on each occurence in source the function is applied to the current value of the behaviour and the value of the occurence, the returned value becomes the next value of the behavior.

    Type parameters

    • A

    • B

    Parameters

    • fn: function
        • (a: A, b: B): B
        • Parameters

          • a: A
          • b: B

          Returns B

    • init: B
    • source: Stream<A>

    Returns Behavior<Behavior<B>>

sink

  • Creates a behavior for imperative impure pushing.

    Type parameters

    • A

    Parameters

    • initialValue: A

    Returns Behavior<A>

snapshot

  • Creates a future than on occurence samples the current value of the behavior and occurs with that value. That is, the original value of the future is overwritten with the behavior value at the time when the future occurs.

    Type parameters

    • A

    Parameters

    Returns Behavior<Future<A>>

stepper

  • Creates a Behavior whose value is the last occurrence in the stream.

    Type parameters

    • B

    Parameters

    • initial: B

      the initial value that the behavior has

    • steps: Stream<B>

      the stream that will change the value of the behavior

    Returns Behavior<B>

subscribe

  • subscribe<A>(fn: function, b: Behavior<A>): void
  • Subscribe to a behavior in order to run imperative actions when the value in the behavior changes.

    Type parameters

    • A

    Parameters

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

          • a: A

          Returns void

    • b: Behavior<A>

    Returns void

switcher

  • From an initial behavior and a future of a behavior switcher creates a new behavior that acts exactly like initial until next occurs after which it acts like the behavior it contains.

    Type parameters

    • A

    Parameters

    Returns Behavior<A>

when

  • Take a behavior b of booleans and return a behavior that for time t contains a future that occurs when b is true after t.

    Parameters

    • b: Behavior<boolean>

      A boolean valued behavior.

    Returns Behavior<Future<object>>

Generated using TypeDoc