Function Observable

Rocket.makeFunction
make(f::Function, type::Type{D})

Creation operator for the FunctionObservable.

Arguments

  • f: function to be invoked on subscription
  • type: type of data in observable

Examples

using Rocket

source = make(Int) do actor
    next!(actor, 0)
    complete!(actor)
end

subscription = subscribe!(source, logger());
unsubscribe!(subscription)
;

# output

[LogActor] Data: 0
[LogActor] Completed
using Rocket

source = make(Int) do actor
    next!(actor, 0)
    setTimeout(100) do
        next!(actor, 1)
        complete!(actor)
    end
end

subscription = subscribe!(source, logger())
unsubscribe!(subscription)
;

# output

[LogActor] Data: 0

See also: FunctionObservable, subscribe!, logger

source
Rocket.FunctionObservableType
FunctionObservable{D}(f::F)

FunctionObservable wraps a callback f, which is called when the Observable is initially subscribed to. This function is given an Actor, to which new values can be nexted (with next!(actor, data)), or an error! method can be called to raise an error, or complete! can be called to notify of a successful completion.

Arguments

  • f::F: function to be invoked on subscription

See also: Subscribable, make

source