Teardown API
Any subscription-like object should implement a valid teardown logic.
Example
using Rocket
struct MuCustomSubscription <: Teardown
# some fields here
end
Rocket.as_teardown(::Type{<:MuCustomSubscription}) = UnsubscribableTeardownLogic()
function on_unsubscribe!(subscription::MyCustomSubscription)
# dispose resources here
endTraits
Rocket.TeardownLogic — TypeAbstract type for all possible teardown logic traits.
See also: UnsubscribableTeardownLogic, CallableTeardownLogic, VoidTeardownLogic, InvalidTeardownLogic
Rocket.as_teardown — Functionas_teardown(::Type)This function checks teardown trait behavior specification. Should be used explicitly to specify teardown logic trait behavior for any object.
Examples
using Rocket
struct MySubscription <: Teardown end
Rocket.as_teardown(::Type{<:MySubscription}) = UnsubscribableTeardownLogic()
Rocket.on_unsubscribe!(s::MySubscription) = println("Unsubscribed!")
subscription = MySubscription()
unsubscribe!(subscription)
;
# output
Unsubscribed!See also: Teardown, TeardownLogic
Rocket.UnsubscribableTeardownLogic — TypeUnsubscribable teardown logic trait behavior. Unsubscribable teardown object must define its own method for on_unsubscribe!() function which will be invoked when actor decides to unsubscribe! from Observable.
See also: TeardownLogic, on_unsubscribe!, unsubscribe!
Rocket.on_unsubscribe! — Functionon_unsubscribe!(teardown)Each valid teardown object with UnsubscribableTeardownLogic trait behavior must implement its own method for on_unsubscribe!() function which will be invoked when actor decides to unsubscribe! from Observable.
See also: Teardown, TeardownLogic, UnsubscribableTeardownLogic
Rocket.CallableTeardownLogic — TypeCallable teardown logic trait behavior. Callable teardown object must be callable (insert meme with a surprised Pikachu here).
See also: TeardownLogic, on_unsubscribe!, unsubscribe!
Rocket.VoidTeardownLogic — TypeVoid teardown logic trait behavior. Void teardown object does nothing in unsubscribe! and may not define any additional methods.
See also: TeardownLogic, on_unsubscribe!, unsubscribe!
Rocket.InvalidTeardownLogic — TypeDefault teardown logic trait behavour. Invalid teardwon object cannot be used in unsubscribe! function. Doing so will raise an error.
See also: TeardownLogic, on_unsubscribe!, unsubscribe!
Types
Rocket.Teardown — TypeAbstract type for any teardown object. Each teardown object must be a subtype of Teardown.
See also: TeardownLogic
Rocket.unsubscribe! — Functionunsubscribe!(subscription)
unsubscribe!(subscriptions::Tuple)
unsubscribe!(subscriptions::AbstractVector)unsubscribe! function is used to cancel Observable execution and to dispose any kind of resources used during an Observable execution. If the input argument to the unsubscribe! function is either a tuple or a vector, it will first check that all of the arguments are valid subscription objects and if its true will unsubscribe from each of them individually.
See also: Teardown, TeardownLogic, on_unsubscribe!
Errors
Rocket.InvalidTeardownLogicTraitUsageError — TypeThis error will be thrown if unsubscribe! function is called with invalid teardown object.
See also: unsubscribe!
Rocket.InvalidMultipleTeardownLogicTraitUsageError — TypeThis error will be thrown if unsubscribe! function is called with a tuple with invalid teardown object in it.
See also: unsubscribe!
Rocket.MissingOnUnsubscribeImplementationError — TypeThis error will be thrown if Julia cannot find specific method of on_unsubscribe!() function for given teardown object.
See also: on_unsubscribe!