Class: Subscription

(abstract, private) subscriptionClasses.Subscription(url, titleopt)

The Subscription class represents a filter subscription.

Constructor

(abstract, private) new Subscription(url, titleopt)

Creates a Subscription object.

Parameters:
Name Type Attributes Description
url string

The URL of the subscription.

title string <optional>

The title of the subscription.

Source:

Members

(package, static) knownSubscriptions :Map.<string, module:subscriptionClasses.Subscription>

Cache for known filter subscriptions that maps subscription URLs to subscription objects.

Type:
Source:

(private) _disabled :boolean

Whether the subscription is disabled.

Type:
  • boolean
Default Value:
  • false
Source:
See:

(private) _filterText :Array.<string>

Filter text contained in the subscription.

Type:
  • Array.<string>
Source:

(private) _filterTextIndex :Set.<string>

A searchable index of filter text in the subscription.

Type:
  • Set.<string>
Source:

(private) _fixedTitle :boolean

Whether the title of the subscription is non-editable.

Type:
  • boolean
Default Value:
  • false
Source:
See:

(private, nullable) _title :string

The title of the subscription.

Type:
  • string
Default Value:
  • null
Source:
See:

(private, nullable) _type :string

The type of the subscription.

Type:
  • string
Default Value:
  • null
Source:
See:

(private) _url :string

The URL of the subscription.

Type:
  • string
Source:
See:

(private) _urlValid :boolean

Whether the URL of the subscription is a valid subscription URL.

Type:
  • boolean
Source:
See:

disabled :boolean

Whether the subscription is disabled.

Type:
  • boolean
Default Value:
  • false
Source:

filterCount :number

The number of filters in the subscription.

Type:
  • number
Default Value:
  • 0
Source:

fixedTitle :boolean

Whether the title of the subscription is non-editable.

Type:
  • boolean
Default Value:
  • false
Source:

privileged :bool

True if this subscription can load filters that require privileged access, like snippets.

Type:
  • bool
Source:

title :string

The title of the subscription.

Type:
  • string
Source:

(nullable) type :string

The type of the subscription.

Type:
  • string
Default Value:
  • null
Source:

url :string

The URL of the subscription.

Type:
  • string
Source:

(package) valid :boolean

Whether the subscription is valid.

Type:
  • boolean
Source:

Methods

(package, static) fromObject(obj) → {module:subscriptionClasses.Subscription}

Deserializes a subscription.

Parameters:
Name Type Description
obj Object

A map of serialized properties and their values.

Source:
Returns:

A subscription object.

Type
module:subscriptionClasses.Subscription

(static) fromURL(url) → {module:subscriptionClasses.Subscription}

Returns the subscription object for a subscription URL.

Every subscription URL maps to its own unique object. If no such object exists, a new one is created internally; otherwise the existing object is used.

Parameters:
Name Type Description
url string

The subscription URL.

Source:
Returns:

A subscription object.

Type
module:subscriptionClasses.Subscription

(static) isValidURL(url) → {boolean}

Checks whether a URL is a valid subscription URL.

Parameters:
Name Type Description
url string

The URL.

Source:
Returns:

Whether the URL is a valid subscription URL.

Type
boolean

addFilter(filter)

Adds a filter to the subscription.

Parameters:
Name Type Description
filter Filter

The filter.

Source:

clearFilters()

Removes all filters from the subscription.

Source:

deleteFilterAt(index)

Deletes a filter from the subscription at the given 0-based index.

Parameters:
Name Type Description
index number

The 0-based index. If the index is out of bounds, no filter is deleted.

Source:

filterText() → {Iterator.<string>}

Returns an iterator that yields the text for each filter in the subscription.

Source:
Returns:
Type
Iterator.<string>

filterTextAt(index) → (nullable) {module:filterClasses.Filter}

Returns the filter text at the given 0-based index.

Parameters:
Name Type Description
index number

The 0-based index. If the index is out of bounds, the return value is null.

Source:
Returns:

The filter text.

Type
module:filterClasses.Filter

findFilterIndex(filter, fromIndexopt) → {number}

Returns the 0-based index of the given filter.

Parameters:
Name Type Attributes Default Description
filter module:filterClasses.Filter

The filter.

fromIndex number <optional>
0

The 0-based index from which to start the search.

Source:
Returns:

The 0-based index at which the filter is found. If the filter is not found in the subscription, the return value is -1.

Type
number

(package) hasFilterText(filterText) → {boolean}

Checks whether the subscription has the given filter text.

Parameters:
Name Type Description
filterText string

The filter text.

Source:
Returns:

Whether the subscription has the filter text.

Type
boolean

insertFilterAt(filter, index)

Inserts a filter into the subscription at the given 0-based index.

Parameters:
Name Type Description
filter module:filterClasses.Filter

The filter.

index number

The 0-based index. If the index is out of bounds, the filter is inserted at the beginning or at the end accordingly.

Source:

(generator, package) serialize() → {string}

Serializes the subscription for writing out on disk.

Source:
Yields:
Type
string

(generator, package) serializeFilters() → {string}

Serializes the subscription's filter text for writing out on disk.

Source:
Yields:
Type
string

toString() → {string}

Returns a string representing the subscription.

Source:
Returns:
Type
string

(package) updateFilterText(filterText) → {Object}

Updates the filter text of the subscription.

Parameters:
Name Type Description
filterText Array.<string>

The new filter text.

Source:
Returns:

An object containing two lists of the text of added and removed filters respectively.

Type
Object