Caplin Trader 4.7.1

Class: module:caplin/sljsadapter/providers/StreamLinkWatchlistService

module:caplin/sljsadapter/providers/StreamLinkWatchlistService

A service for the creation and disposal of shareable watchlists via streamlink.

This class is an emitter, triggering the events in module:caplin/watchlist/WatchlistServiceEvents when watchlists are added or removed, or the service status has changed. When your component first listens to the STATUS_CHANGED event, it will immediately be notified of the current service status. When your component listens to the ADDED event, it will immediately be notified of all existing watchlists, if any exist.

To see example code snippets using this service, look at the package documentation caplin/watchlist.

Constructor

new module:caplin/sljsadapter/providers/StreamLinkWatchlistService()

Implements:

Methods

create(name, erroropt, successopt)

This method is meant to be invoked by UI components wishing to create a new shareable watchlist. The newly created watchlist will be represented on the front-end by a module:caplin/sljsadapter/watchlist/StreamLinkWatchlist. This method submits a contrib to streamlink to create the new watchlist.

If the request is successful, an ADDED event will be raised (see module:caplin/watchlist/WatchlistServiceEvents) and the newly created watchlist object will be passed. If the requested watchlist has not been created by streamlink after the timeout has elapsed, error will be called.

Parameters:
Name Type Attributes Description
name String The presentation name for the watchlist.
error function <optional>
A callback that will be invoked if the request times out.
success module:caplin/sljsadapter/providers/StreamLinkWatchlistService~createSuccessCallback <optional>
A callback that will be invoked when the backend reports that the new watchlist is successfully added.
Implements:
See:
Throws:
If required properties are not included, or if error and success are not functions.
Type
module:br/Errors.INVALID_PARAMETERS

dispose(watchlists, erroropt, successopt)

A request to dispose of the given watchlists, removing them from the user's list of watchlists.

If the request is successful, a REMOVED event will be raised for each watchlist removed (see module:caplin/watchlist/WatchlistServiceEvents). If all the watchlists have not been removed by streamlink after the timeout has elapsed, error will be called.

Parameters:
Name Type Attributes Description
watchlists Array.<module:caplin/watchlist/Watchlist> The watchlists to dispose of.
error function <optional>
A callback that will be invoked if the request fails.
success function <optional>
A callback that will be invoked when the request succeeds.
Implements:
See:
Throws:
If the given watchlists are not Watchlists, not found in the current list, or if error and success are not functions.
Type
module:br/Errors.INVALID_PARAMETERS

getById()

Implements:

getWatchlistCount()

Implements:

getWatchlists()

Implements:

setRequestTimeout(duration)

Set the duration in milliseconds for how long to wait after a contrib before timing out and calling the error callback. If this method is never called, the timeout defaults to module:caplin/sljsadapter/watchlist/StreamLinkWatchlistServiceConstants#CONTRIB_TIMEOUT
Parameters:
Name Type Description
duration Number duration in milliseconds for timeouts for contribs to back-end

Type Definitions

createSuccessCallback(watchlist)

A callback function called upon success of module:caplin/sljsadapter/providers/StreamLinkWatchlistService#create.
Parameters:
Name Type Description
watchlist module:caplin/sljsadapter/watchlist/StreamLinkWatchlist The newly created watchlist object.