module Stream(T)

Overview

A suckless reactive stream toolkit.

Defined in:

aspis/stream.cr

Constructors

Instance Method Summary

Constructor Detail

def self.new #

Creates and returns a stream.


[View source]

Instance Method Detail

def all(from a : Stream(M), until b : Stream(K), now = false) forall M, K #

Starts to emit when a emits, and stops to emit when b emits. now can be passed to skip waiting for a to emit the first time.


[View source]
def batch(count : Int32) #

Emits objects from this stream in batches of count elements.


[View source]
def each(func : T -> ) #

Calls func before emitting an object unchanged.


[View source]
def each(&func : T -> ) #

Calls func before emitting an object unchanged.


[View source]
def emit(object : T) #

Emits object to all streams that are subscribed to this stream.


[View source]
def forget(stream) #

Unsubscribes stream from events in this stream.


[View source]
def join(other : Stream(T)) #

Unordrered concatenation: emits objects from both streams.


[View source]
def map(&func : T -> U) forall U #

Emits an object transformed by func.


[View source]
def notifies(stream) #

Subscribes stream to this stream.


[View source]
def reject(&func : T -> Bool) #

Emits only those objects for which func returns false.


[View source]
def reject(pattern) #

Emits only those objects that do not match against pattern (using ===).


[View source]
def select(&func : T -> Bool) #

Emits only those objects for which func returns true.


[View source]
def select(type : U.class) forall U #

Emits only those objects that are of the given type.


[View source]
def select(pattern) #

Emits only those objects that match against pattern (using ===).


[View source]
def uniq(&func : T -> U) forall U #

Emits only if the result of func is not equal (==) to the last emitted value.

The first object is always emitted.


[View source]
def uniq #

Emits only if the emitted object is not equal to the previous emitted object.


[View source]
def zip(other : Stream(U)) : Stream(Tuple(T, U)) forall U #

[View source]