Raxol.UI.State.Streams (Raxol v2.0.1)

View Source

Reactive streams system for real-time data flow in Raxol UI.

Refactored version with pure functional error handling patterns. All try/catch blocks have been replaced with with statements and proper error tuples.

This module provides RxJS-like reactive programming capabilities with:

  • Observable streams of data
  • Operators for transforming data (map, filter, reduce, etc.)
  • Hot and cold observables
  • Backpressure handling
  • Functional error handling and retry strategies
  • Subscription management
  • Combining multiple streams

Summary

Functions

Combines latest values from multiple streams.

Debounces values, only emitting after a period of silence.

Filters values in the stream based on a predicate.

Creates an observable from UI events.

Creates an observable from a list of values.

Creates an observable from a range of numbers.

Creates an observable from Store state changes.

Creates an observable that emits values at regular intervals.

Transforms values in the stream using a mapping function.

Reduces values in the stream to a single value.

Skips the first N values from the stream.

Subscribes to an observable with an observer or simple next function.

Takes only the first N values from the stream.

Creates an observable that emits a single value after a delay.

Unsubscribes from an observable.

Functions

cancel_existing_timer(timer)

combine_latest(observables)

Combines latest values from multiple streams.

debounce(observable, milliseconds)

Debounces values, only emitting after a period of silence.

emit_debounced_value(value, observer)

filter(observable, predicate_fn)

Filters values in the stream based on a predicate.

from_events(event_type)

Creates an observable from UI events.

from_list(list)

Creates an observable from a list of values.

Examples

numbers = Streams.from_list([1, 2, 3, 4, 5])
Streams.subscribe(numbers, fn x -> Log.info(x) end)

from_range(range)

Creates an observable from a range of numbers.

from_store_path(path, store \\ Store)

Creates an observable from Store state changes.

interval(milliseconds, value_fn \\ fn i -> i end)

Creates an observable that emits values at regular intervals.

map(observable, mapper_fn)

Transforms values in the stream using a mapping function.

reduce(observable, initial, reducer_fn)

Reduces values in the stream to a single value.

skip(observable, count)

Skips the first N values from the stream.

subscribe(observable, observer_or_fn)

Subscribes to an observable with an observer or simple next function.

take(observable, count)

Takes only the first N values from the stream.

timer(milliseconds, value)

Creates an observable that emits a single value after a delay.

unsubscribe(subscription)

Unsubscribes from an observable.