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
end

Traits

Rocket.as_teardownFunction
as_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

source

Types

Rocket.unsubscribe!Function
unsubscribe!(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!

source

Errors