Stream.apex

  • Docs
  • Tutorials
Docs Menu
  • Streams
  • Methods
    • Creation Methods
    • Functions
    • Subscription Methods
    • Operation Methods
  • Subject

Creation Methods Guide

Creation Methods

create

Create from stream source

Stream.create(new CustomSource())
     .subscribe(R.debug);

of

Create from value

Stream.of('abc')
     .subscribe(R.debug);
// abc

throwError

Create from error

Stream.throwError('test error')
     .subscribe(R.debug, R.debug.apply('Error: '), R.debug.apply('Completed'));
// (Error: , test error)

empty

Create an empty stream

Stream.empty()
     .subscribe(R.debug, R.debug.apply('Error: '), R.debug.apply('Completed'));
// Completed

never

Create a stream that does not emit error or complete event.

Stream.never()
    .subscribe(R.debug, R.debug.apply('Error: '), R.debug.apply('Completed'));

fromData

Create a stream from a collection

Stream.fromData(new List{ 1, 2, 3 })
    .subscribe(R.debug, R.debug.apply('Error: '), R.debug.apply('Completed'));
// 1
// 2
// 3
// Completed

with

Create a stream from values

Stream.with(1)
    .subscribe(R.debug, R.debug.apply('Error: '), R.debug.apply('Completed'));
// 1
// Completed
MethodDescription
with(Object)Create a stream from one value
with(Object, Object)Create a stream from two values
with(Object, Object, Object)Create a stream from three values

range

Create a stream from ranges of values

Stream.range(1, 3)
    .subscribe(R.debug, R.debug.apply('Error: '), R.debug.apply('Completed'));
// 1
// 2
// 3
// Completed

generate

Generate a stream with the Funcs

Stream.generate(1, R.lt.apply(R.placeholder, 4), R.inc)
    .subscribe(R.debug, R.debug.apply('Error: '), R.debug.apply('Completed'));
// 1
// 2
// 3
// Completed

concat

Create a stream by concatenating other streams

Stream.concat(new List{ Stream.of(1), Stream.of(2), Stream.of(3) })
    .subscribe(R.debug, R.debug.apply('Error: '), R.debug.apply('Completed'));
// 1
// 2
// 3
// Completed
MethodDescription
concat(Stream)Concat one stream
concat(Stream, Stream)Concat two streams
concat(Stream, Stream, Stream)Concat three streams

Contribute on Github! Edit this section.