TinyBase logoTinyBase

addHasSliceListener

The addHasSliceListener method registers a listener function with the Indexes object that will be called whenever a Slice is added to or removed from an Index.

addHasSliceListener(
  indexId: IdOrNull,
  sliceId: IdOrNull,
  listener: HasSliceListener,
): string
TypeDescription
indexIdIdOrNull

The Id of the Index to listen to, or null as a wildcard.

sliceIdIdOrNull

The Id of the Slice to listen to, or null as a wildcard.

listenerHasSliceListener

The function that will be called whenever the Slice is added or removed.

returnsstring

A unique Id for the listener that can later be used to remove it.

You can either listen to a single Slice (by specifying the Index Id and Slice Id as the method's first two parameters), or changes to any Slice (by providing null wildcards).

Both, either, or neither of the indexId and sliceId parameters can be wildcarded with null. You can listen to a specific Slice in a specific Index, any Slice in a specific Index, a specific Slice in any Index, or any Slice in any Index.

The provided listener is a HasSliceListener function, and will be called with a reference to the Indexes object, the Id of the Index, the Id of the Slice that changed, and whether it now exists.

Since

v9.1.0