AbstractChannelService
On this page
- AbstractChannelService ⇐
Abstract
- AbstractChannelService()
- newChannel(properties) ⇒
AbstractChannel
- setCurrentChannelListId(listId, [type], [options]) ⇒
Promise.<Object, Error>
- getCurrentChannelListId() ⇒
Promise.<Object, Error>
- getChannelList([options]) ⇒
Promise.<ChannelList, Error>
- find(filterFunction, [options]) ⇒
Promise.<Array.<AbstractChannel>, Error>
- getTVChannelList([options]) ⇒
Promise.<Array.<AbstractChannel>>
- getRadioChannelList([options]) ⇒
Promise.<Array.<AbstractChannel>>
- getApplicationChannelList([options]) ⇒
Promise.<Array.<AbstractChannel>>
- getOtherChannelList([options]) ⇒
Promise.<Array.<AbstractChannel>>
- getFavoriteList(favoriteListId, [options]) ⇒
Promise.<Array.<AbstractChannel>, Error>
- getBlockedList([options]) ⇒
Promise.<Array.<AbstractChannel>, Error>
- getChannel(id, [options]) ⇒
Promise.<AbstractChannel>
- getPreferredChannel() ⇒
Promise.<AbstractChannel, Error>
- getNextChannel(channel, [options]) ⇒
Promise.<AbstractChannel, Error>
- getPreviousChannel(channel, [options]) ⇒
Promise.<AbstractChannel, Error>
- getNearestChannel(channel, [options]) ⇒
AbstractChannel
- getChannelByNumber(number, [options]) ⇒
Promise.<AbstractChannel, Error>
- _newChannel(properties) ⇒
*
- _getAllList([options]) ⇒
Promise.<Array.<AbstractChannel>, Error>
- _reload([options]) ⇒
Promise.<boolean, error>
- _getPreferredChannel() ⇒
Promise.<AbstractChannel, Error>
- _getChannel(id, channelList) ⇒
Channel
|Promise.<Channel, Error>
- invalidateCache([options]) ⇒
Promise
- reload([options]) ⇒
Promise.<boolean, error>
- _onChannelListChange(newChannelListDef, oldChannelListDef) ⇒
Promise
- “channelListChange” (newChannelListDef, oldChannelListDef)
- ALL_CHANNEL_LIST_ID :
string
- BLOCKED_CHANNEL_LIST_ID :
string
- byNumberComparator(a, b) ⇒
number
- byTypeFilter(type) ⇒
function
AbstractChannelService ⇐ Abstract
Kind: global abstract class
Extends: Abstract
Mixes: MFavoritesAndBlockedList
, MServiceCache
Service:
- AbstractChannelService ⇐
Abstract
- new AbstractChannelService()
- instance
- .newChannel(properties) ⇒
AbstractChannel
- .setCurrentChannelListId(listId, [type], [options]) ⇒
Promise.<Object, Error>
- .getCurrentChannelListId() ⇒
Promise.<Object, Error>
- .getChannelList([options]) ⇒
Promise.<ChannelList, Error>
- .find(filterFunction, [options]) ⇒
Promise.<Array.<AbstractChannel>, Error>
- .getTVChannelList([options]) ⇒
Promise.<Array.<AbstractChannel>>
- .getRadioChannelList([options]) ⇒
Promise.<Array.<AbstractChannel>>
- .getApplicationChannelList([options]) ⇒
Promise.<Array.<AbstractChannel>>
- .getOtherChannelList([options]) ⇒
Promise.<Array.<AbstractChannel>>
- .getFavoriteList(favoriteListId, [options]) ⇒
Promise.<Array.<AbstractChannel>, Error>
- .getBlockedList([options]) ⇒
Promise.<Array.<AbstractChannel>, Error>
- .getChannel(id, [options]) ⇒
Promise.<AbstractChannel>
- .getPreferredChannel() ⇒
Promise.<AbstractChannel, Error>
- .getNextChannel(channel, [options]) ⇒
Promise.<AbstractChannel, Error>
- .getPreviousChannel(channel, [options]) ⇒
Promise.<AbstractChannel, Error>
- .getNearestChannel(channel, [options]) ⇒
AbstractChannel
- .getChannelByNumber(number, [options]) ⇒
Promise.<AbstractChannel, Error>
- ._newChannel(properties) ⇒
*
- ._getAllList([options]) ⇒
Promise.<Array.<AbstractChannel>, Error>
- ._reload([options]) ⇒
Promise.<boolean, error>
- ._getPreferredChannel() ⇒
Promise.<AbstractChannel, Error>
- ._getChannel(id, channelList) ⇒
Channel
|Promise.<Channel, Error>
- .invalidateCache([options]) ⇒
Promise
- .reload([options]) ⇒
Promise.<boolean, error>
- ._onChannelListChange(newChannelListDef, oldChannelListDef) ⇒
Promise
- “channelListChange” (newChannelListDef, oldChannelListDef)
- .newChannel(properties) ⇒
- static
- .ALL_CHANNEL_LIST_ID :
string
- .BLOCKED_CHANNEL_LIST_ID :
string
- .byNumberComparator(a, b) ⇒
number
- .byTypeFilter(type) ⇒
function
- .ALL_CHANNEL_LIST_ID :
AbstractChannelService()
This class represents the service that handles the channels.
newChannel(properties) ⇒ AbstractChannel
Create a new channel model. It is preferred to use this method instead of using new $Channel(), as this method will always create the model with the right implementation.
Kind: instance method of AbstractChannelService
Returns: AbstractChannel
- The channel model
Param | Type | Description |
---|---|---|
properties | Object | The model of properties |
setCurrentChannelListId(listId, [type], [options]) ⇒ Promise.<Object, Error>
Change the current list.
Kind: instance method of AbstractChannelService
Returns: Promise.<Object, Error>
- Returns a promise resolved with {listId:listId, type:listType}
or rejected if the list does not exist
Emits: channelListChange
Param | Type | Description |
---|---|---|
listId | string | A predefined list identifier or a favorite list identifier |
[type] | number | The channel type. See: $Channel.XXX_TYPE |
[options] | Object | Additional options |
[options.skipNotify] | boolean | If true do not fire the onChannelListChange event |
getCurrentChannelListId() ⇒ Promise.<Object, Error>
Get the current list identifier.
Kind: instance method of AbstractChannelService
Returns: Promise.<Object, Error>
- Returns a promise resolved with {id:listId, type:listType}
getChannelList([options]) ⇒ Promise.<ChannelList, Error>
Get the channels of the current channel list, sorted by LCN. You can use the listId option to get a the channel of a specific list.
Kind: instance method of AbstractChannelService
Returns: Promise.<ChannelList, Error>
- A promise resolved with an array of channels or rejected in case of problem
Param | Type | Default | Description |
---|---|---|---|
[options] | Object | Additional options | |
[options.type] | number | The type of channel to look for, such as | |
[options.force] | boolean | false | If true, don't use the value stored in the cache |
[options.listId] | string | null | If set, it gets a channel on a specific list |
[options.sort] | function | $ChannelService.byNumberComparator | If a function is specified, will sort the list by channel numbers |
[options.duration] | number |
| Duration in milliseconds before invalidation of cache (if null, $$maxAge value is used by default) |
find(filterFunction, [options]) ⇒ Promise.<Array.<AbstractChannel>, Error>
Find channel(s) using a function as filter.
Kind: instance method of AbstractChannelService
Returns: Promise.<Array.<AbstractChannel>, Error>
- A promise (channel(s), error)
Param | Type | Default | Description |
---|---|---|---|
filterFunction | function | null | A function that takes a channel in arg and return true or false (true mean keep channel) | |
[options] | Object | Additional options | |
[options.force] | boolean | false | If true, don't use the value stored in the cache |
[options.listId] | string | null | If set, it gets a channel on a specific list |
getTVChannelList([options]) ⇒ Promise.<Array.<AbstractChannel>>
Get the list of TV channels, sorted by LCN (i.e. logical channel number).
Kind: instance method of AbstractChannelService
Param | Type | Default | Description |
---|---|---|---|
[options] | Object | Additional options | |
[options.force] | boolean | false | If true, don't use the value stored in the cache |
[options.listId] | string | null | If set, it gets a channel on a specific list |
getRadioChannelList([options]) ⇒ Promise.<Array.<AbstractChannel>>
Get the list of radio channels, sorted by LCN (i.e. logical channel number).
Kind: instance method of AbstractChannelService
Param | Type | Default | Description |
---|---|---|---|
[options] | Object | Additional options | |
[options.force] | boolean | false | If true, don't use the value stored in the cache |
[options.listId] | string | null | If set, it gets a channel on a specific list |
getApplicationChannelList([options]) ⇒ Promise.<Array.<AbstractChannel>>
Get the list of application channels, sorted by LCN (i.e. logical channel number).
Kind: instance method of AbstractChannelService
Param | Type | Default | Description |
---|---|---|---|
[options] | Object | Additional options | |
[options.force] | boolean | false | If true, don't use the value stored in the cache |
[options.listId] | string | null | If set, it gets a channel on a specific list |
getOtherChannelList([options]) ⇒ Promise.<Array.<AbstractChannel>>
Get the list of other channels (neither TV nor radio), sorted by LCN (i.e. logical channel number).
Kind: instance method of AbstractChannelService
Param | Type | Default | Description |
---|---|---|---|
[options] | Object | Additional options | |
[options.force] | boolean | false | If true, don't use the value stored in the cache |
[options.listId] | string | null | If set, it gets a channel on a specific list |
getFavoriteList(favoriteListId, [options]) ⇒ Promise.<Array.<AbstractChannel>, Error>
Get the favorite list by its identifier
Kind: instance method of AbstractChannelService
Returns: Promise.<Array.<AbstractChannel>, Error>
- A promise resolved with an array of channels or rejected in case of problem
Param | Type | Default | Description |
---|---|---|---|
favoriteListId | string | The identifier of the favorite | |
[options] | Object | Additional options | |
[options.type] | number | The type of channel to look for, such as | |
[options.force] | boolean | false | If true, don't use the value stored in the cache |
[options.sort] | function | $ChannelService.byNumberComparator | If a function is specified, will sort the list by channel numbers |
getBlockedList([options]) ⇒ Promise.<Array.<AbstractChannel>, Error>
Get all the blocked channels of a given type (TV or RADIO)
Kind: instance method of AbstractChannelService
Returns: Promise.<Array.<AbstractChannel>, Error>
- A promise resolved with an array of channels or rejected in case of problem
Param | Type | Default | Description |
---|---|---|---|
[options] | Object | Additional options | |
[options.type] | number | The type of channel to look for, such as | |
[options.force] | boolean | false | If true, don't use the value stored in the cache |
[options.sort] | function | $ChannelService.byNumberComparator | If a function is specified, will sort the list by channel numbers |
getChannel(id, [options]) ⇒ Promise.<AbstractChannel>
Get a channel by its identifier. The channel must belong to the list.
Kind: instance method of AbstractChannelService
Returns: Promise.<AbstractChannel>
- A promise resolved with the channel data (or undefined if not found).
Param | Type | Default | Description |
---|---|---|---|
id | string | The channel identifier | |
[options] | Object | Additional options | |
[options.type] | number | The type of channel to look for, such as | |
[options.force] | boolean | false | If true, it refreshes the channel list (i.e. renew the cache) |
[options.listId] | string | null | If set, it gets a channel on a specific list |
getPreferredChannel() ⇒ Promise.<AbstractChannel, Error>
Get a preferred channel
Kind: instance method of AbstractChannelService
Returns: Promise.<AbstractChannel, Error>
- A promise resolved a channel or rejected in case of problem
getNextChannel(channel, [options]) ⇒ Promise.<AbstractChannel, Error>
Get the channel after a given one.
Kind: instance method of AbstractChannelService
Returns: Promise.<AbstractChannel, Error>
- A promise (next channel object, error).
Param | Type | Default | Description |
---|---|---|---|
channel | number | AbstractChannel | The reference channel number or object. If a number is given, it does not have to exist in the channel list. | |
[options] | Object | ||
[options.type] | number | The type of channel to look for, such as | |
[options.cyclic] | boolean | true | Whether or not to loop at the end of the channel list. |
[options.force] | boolean | false | If true, it refreshes the channel list (i.e. renew the cache) |
[options.listId] | string | null | If set, it gets a channel on a specific list |
getPreviousChannel(channel, [options]) ⇒ Promise.<AbstractChannel, Error>
Get the channel before a given one.
Kind: instance method of AbstractChannelService
Returns: Promise.<AbstractChannel, Error>
- A promise (next channel object, error).
Param | Type | Default | Description |
---|---|---|---|
channel | number | AbstractChannel | The reference channel number or object. If a number is given, it does not have to exist in the channel list. | |
[options] | object | ||
[options.type] | number | The type of channel to look for, such as | |
[options.cyclic] | boolean | true | Whether or not to loop at the beginning of the channel list. |
[options.force] | boolean | false | If true, it refreshes the channel list (i.e. renew the cache) |
[options.listId] | string | null | If set, it gets a channel on a specific list |
getNearestChannel(channel, [options]) ⇒ AbstractChannel
Returns the closest channel by number.
Kind: instance method of AbstractChannelService
Returns: AbstractChannel
- channel, or undefined if the channel list was empty.
Param | Type | Default | Description |
---|---|---|---|
channel | number | AbstractChannel | the reference channel, or its number. | |
[options] | object | ||
[options.type] | number | The type of channel to look for, such as | |
[options.cyclic] | boolean | true | Whether or not to loop at the beginning and the end of the channel list. |
[options.listId] | string | null | If set, get channel on a specific list |
[options.strategy] | "round" | "floor" | "ceil" | "round" | If given, define the strategy to adopt to search through the channel list |
[options.channelList] | Array.<AbstractChannel> |
| If set, gives the channel list through which the search should be made |
getChannelByNumber(number, [options]) ⇒ Promise.<AbstractChannel, Error>
Get channel by its number
Kind: instance method of AbstractChannelService
Returns: Promise.<AbstractChannel, Error>
- a promise
Param | Type | Default | Description |
---|---|---|---|
number | number | Number of the channel (integer) | |
[options] | object | ||
[options.type] | number | The type of channel to look for, such as | |
[options.force] | boolean | false | If true, refresh the channel list (ie renew the cache) |
[options.listId] | string | null | If set, get channel on a specific list |
_newChannel(properties) ⇒ *
Kind: instance abstract method of AbstractChannelService
Param | Type |
---|---|
properties | Object |
_getAllList([options]) ⇒ Promise.<Array.<AbstractChannel>, Error>
Vendor implementation to get the list that contains all channels
⚠ WARNING: DON’T FORGET TO MARK THE CHANNELS BLOCKED WITH THE isUserBlocked PROPERTY !!!
Kind: instance abstract method of AbstractChannelService
Returns: Promise.<Array.<AbstractChannel>, Error>
- A promise resolved with an array of channels or rejected in case of problem
Param | Type | Description |
---|---|---|
[options] | Object | Additional options |
_reload([options]) ⇒ Promise.<boolean, error>
Default implementation to reload the list. (By default, it invalidates the cache)
Kind: instance method of AbstractChannelService
Returns: Promise.<boolean, error>
- A promise resolved to true if the list have been reloaded
Param | Type | Default | Description |
---|---|---|---|
[options] | Object | Additional options | |
[options.listId] | string | null | If set, it reloads a specific channel list otherwise it invalidates the current channel list |
_getPreferredChannel() ⇒ Promise.<AbstractChannel, Error>
Vendor implementation to get the preferred channel
Kind: instance abstract method of AbstractChannelService
Returns: Promise.<AbstractChannel, Error>
- A promise resolved a channel or rejected in case of problem
_getChannel(id, channelList) ⇒ Channel
| Promise.<Channel, Error>
Given the channelList, this method gets the channel by its identifier.
Kind: instance method of AbstractChannelService
Returns: Channel
| Promise.<Channel, Error>
- the found channel, null otherwise
Access: protected
Param | Type | Description |
---|---|---|
id | string | the channel id |
channelList | ChannelList | the channel list |
invalidateCache([options]) ⇒ Promise
Invalidate the cache forcing the next call to getChannelList to refresh the list from the vendor
Kind: instance method of AbstractChannelService
Param | Type | Default | Description |
---|---|---|---|
[options] | Object | Additional options | |
[options.listId] | string | null | If set invalidate a specific channel list, else invalidate the current channel list |
reload([options]) ⇒ Promise.<boolean, error>
Reload the list (i.e. check if there is an update and re-new the cache)
Kind: instance method of AbstractChannelService
Returns: Promise.<boolean, error>
- A promise resolved to true if the list have been reloaded
Param | Type | Default | Description |
---|---|---|---|
[options] | Object | Additional options | |
[options.listId] | string | null | If set invalidate a specific channel list, else invalidate the current channel list |
_onChannelListChange(newChannelListDef, oldChannelListDef) ⇒ Promise
Kind: instance method of AbstractChannelService
Access: protected
Param | Type |
---|---|
newChannelListDef | Array.<AbstractChannel> |
oldChannelListDef | Array.<AbstractChannel> |
“channelListChange” (newChannelListDef, oldChannelListDef)
Fired when the current list has been changed
Kind: event emitted by AbstractChannelService
Param | Type | Description |
---|---|---|
newChannelListDef | Object | The new list |
oldChannelListDef | Object | The old list |
ALL_CHANNEL_LIST_ID : string
List of all channels identifiers
Kind: static constant of AbstractChannelService
BLOCKED_CHANNEL_LIST_ID : string
List of blocked channels identifiers
Kind: static constant of AbstractChannelService
byNumberComparator(a, b) ⇒ number
A Comparator that can be used to compare two channels by their channels number
Kind: static method of AbstractChannelService
Param | Type |
---|---|
a | Channel |
b | Channel |
byTypeFilter(type) ⇒ function
Return a closure to be used in find for filtering channels by type
Kind: static method of AbstractChannelService
Returns: function
- The callback to be used in find
Param | Type | Description |
---|---|---|
type | number | The channel type. See: $Channel.XXX_TYPE |
Example
$ChannelService.getInstance().find($ChannelService.byTypeFilter($Channel.TV_TYPE)); // the list of current TV channels