Observables API
Any observable-like should implement a valid subscribable logic.
Traits
Rocket.as_subscribable — Functionas_subscribable(any)This function checks subscribable trait behavior specification. Can be used explicitly to specify subscribable trait behavior for any object.
See also: SubscribableTrait
Rocket.SubscribableTrait — TypeAbstract type for all possible subscribable traits
See also: SimpleSubscribableTrait, ScheduledSubscribableTrait, InvalidSubscribableTrait
Rocket.SimpleSubscribableTrait — TypeSimple subscribable trait behavior. Simple subscribable can be used in subscribe! function and just executes on_subscribe! method for provided subscribable. SimpleSubscribableTrait is a subtype of SubscribableTrait.
See also: SubscribableTrait, Subscribable, subscribe!, on_subscribe!
Rocket.ScheduledSubscribableTrait — TypeScheduled subscribable trait behavior. Scheduled subscribable can be used in subscribe! function and executes on_subscribe! method for provided subscribable with custom scheduling. ScheduledSubscribableTrait is a subtype of SubscribableTrait.
See also: SubscribableTrait, ScheduledSubscribable, subscribe!, on_subscribe!
Rocket.InvalidSubscribableTrait — TypeDefault subscribable trait behavior for all types. Invalid subscribable cannot be used in subscribe! function, doing so will throw an error. InvalidSubscribableTrait is a subtype of SubscribableTrait.
See also: SubscribableTrait, subscribe!
Types
Rocket.AbstractSubscribable — TypeSupertype type for Subscribable and ScheduledSubscribable types.
See also: Subscribable, ScheduledSubscribable
Rocket.Subscribable — TypeSuper type for any simple subscribable object. Automatically specifies a SimpleSubscribableTrait trait behavior. Objects with specified SimpleSubscribableTrait subscribable trait must implement: on_subscribe!(subscribable, actor) method. Subscribable is a subtype of AbstractSubscribable type.
Examples
using Rocket
struct MySubscribable <: Subscribable{String} end
Rocket.as_subscribable(MySubscribable)
# output
SimpleSubscribableTrait{String}()See also: SubscribableTrait, SimpleSubscribableTrait
Rocket.ScheduledSubscribable — TypeSuper type for any scheduled subscribable object. Automatically specifies a ScheduledSubscribableTrait trait behavior. Objects with specified ScheduledSubscribableTrait subscribable trait must implement: on_subscribe!(subscribable, actor, scheduler) method. ScheduledSubscribable is a subtype of AbstractSubscribable type.
Examples
using Rocket
struct MyScheduledSubscribable <: ScheduledSubscribable{String} end
Rocket.as_subscribable(MyScheduledSubscribable)
# output
ScheduledSubscribableTrait{String}()See also: SubscribableTrait, ScheduledSubscribableTrait
Rocket.subscribe! — Functionsubscribe!(subscribable::T, actor::S) where { T, S }
subscribe!(subscribable::T, factory::F) where { T, F <: AbstractActorFactory }
subscribe!(subscriptions::Tuple)
subscribe!(subscriptions::AbstractVector)subscribe! function is used to attach an actor to subscribable. It also checks types of subscribable and actors to be a valid Subscribable and Actor objects respectively. Passing not valid subscribable or/and actor object will throw an error. If the input argument to the subscribe! function is either a tuple or a vector, it will first check that all of the arguments are valid source and actor objects and if its true will subscribe for each of them individually.
Arguments
subscribable: valid subscribable objectactor: valid actor object
Examples
using Rocket
source = from((1, 2, 3))
subscribe!(source, logger())
;
# output
[LogActor] Data: 1
[LogActor] Data: 2
[LogActor] Data: 3
[LogActor] Completedusing Rocket
source = from((1, 2, 3))
subscribe!(source, 1)
;
# output
ERROR: Type Int64 is not a valid actor type.
[...]using Rocket
source = from((1, 2, 3))
subscribe!(1, logger())
;
# output
ERROR: Type Int64 is not a valid subscribable type.
[...]See also: on_subscribe!, as_subscribable
Rocket.on_subscribe! — Functionon_subscribe!(subscribable, actor)
on_subscribe!(subscribable, actor, scheduler)Every valid subscribable object have to define its own method for on_subscribe! function which specifies subscription logic and has return a valid Teardown object.
Objects with specified SimpleSubscribableTrait subscribable trait must implement: on_subscribe!(subscribable, actor) method. Objects with specified ScheduledSubscribableTrait subscribable trait must implement: on_subscribe!(subscribable, actor, scheduler) method.
Arguments
subscribable: Subscribable objectactor: Actor objectscheduler: Scheduler object (only for scheduled subscribables)
Examples
using Rocket
struct MySubscribable <: Subscribable{Int} end
function Rocket.on_subscribe!(subscribable::MySubscribable, actor)
next!(actor, 0)
complete!(actor)
return voidTeardown
end
subscribe!(MySubscribable(), logger())
;
# output
[LogActor] Data: 0
[LogActor] Completedusing Rocket
struct MyScheduledSubscribable <: ScheduledSubscribable{Int} end
Rocket.getscheduler(::MyScheduledSubscribable) = AsapScheduler()
function Rocket.on_subscribe!(subscribable::MyScheduledSubscribable, actor, scheduler)
next!(actor, 0, scheduler)
complete!(actor, scheduler)
return voidTeardown
end
subscribe!(MyScheduledSubscribable(), logger())
;
# output
[LogActor] Data: 0
[LogActor] CompletedSee also: Subscribable, ScheduledSubscribable, SimpleSubscribableTrait, ScheduledSubscribableTrait, Teardown, logger
Errors
Rocket.InvalidSubscribableTraitUsageError — TypeThis error will be thrown if subscribe! function is called with invalid subscribable object
See also: subscribe!
Rocket.InconsistentActorWithSubscribableDataTypesError — TypeThis error will be thrown if subscribe! function is called with inconsistent subscribable and actor objects
See also: subscribe!
Rocket.MissingOnSubscribeImplementationError — TypeThis error will be thrown if Julia cannot find specific method of 'on_subscribe!()' function for given subscribable and actor
See also: on_subscribe!
Rocket.MissingOnScheduledSubscribeImplementationError — TypeThis error will be thrown if Julia cannot find specific method of 'on_subscribe!()' function for given subscribable, actor and scheduler
See also: on_subscribe!