ReactiveX/Rx.rb

View on GitHub
examples/from_array.rb

Summary

Maintainability
A
0 mins
Test Coverage
require 'rx'

array = [1,2,3]

source = Rx::Observable.from_array(array)

subscription = source.subscribe(
    lambda {|x|
        puts 'Next: ' + x.to_s
    },
    lambda {|err|
        puts 'Error: ' + err.to_s
    },
    lambda {
        puts 'Completed'
    })

# => Next: 1
# => Next: 2
# => Next: 3
# => Completed