Subscription
Subscriptions are used in the callback for an Observable. Standard usage is as follows.
-- Constucts an observable which will emit a, b, c via a subscription
Observable.new(function(sub)
sub:Fire("a")
sub:Fire("b")
sub:Fire("c")
sub:Complete() -- ends stream
end)
Functions
new
Subscription.
new
(
fireCallback:
function?
,
failCallback:
function?
,
completeCallback:
function?
,
observableSource:
string?
) →
Subscription
Constructs a new Subscription
Fire
Subscription:
Fire
(
...:
any
) →
(
)
Fires the subscription
Fail
Subscription:
Fail
(
) →
(
)
Fails the subscription, preventing anything else from emitting.
GetFireFailComplete
Subscription:
GetFireFailComplete
(
) →
(
function
,
function
,
function
)
Returns a tuple of fire, fail and complete functions which can be chained into the the next subscription.
return function(source)
return Observable.new(function(sub)
sub:Fire("hi")
return source:Subscribe(sub:GetFireFailComplete())
end)
end
GetFailComplete
Subscription:
GetFailComplete
(
) →
(
function
,
function
)
Returns a tuple of fail and complete functions which can be chained into the the next subscription.
return function(source)
return Observable.new(function(sub)
return source:Subscribe(function(result)
sub:Fire(tostring(result))
end, sub:GetFailComplete()) -- Reuse is easy here!
end)
end
Complete
Subscription:
Complete
(
) →
(
)
Completes the subscription, preventing anything else from being emitted.
IsPending
Subscription:
IsPending
(
) →
boolean
Returns whether the subscription is pending.
Destroy
Subscription:
Destroy
(
) →
(
)
Cleans up the subscription
tip
This will be invoked by the Observable automatically, and should not be called within the usage of a subscription.
Disconnect
Subscription:
Disconnect
(
) →
(
)
Alias for Subscription.Destroy.