MapModel
Defined in: api/node/typescript/models.ts:579 ↗
MapModel provides rows that are generated by a map function based on the rows of another model.
Extends
Section titled “Extends”Model<U>
Type Parameters
Section titled “Type Parameters”T
item type of source model that is mapped to U.
U
the type of the mapped items.
Example
Section titled “Example”Here we have an ArrayModel holding rows of a custom interface Name
and a MapModel that maps the name rows to single string rows.
interface Name { first: string; last: string;}
const model = new ArrayModel<Name>([ { first: "Hans", last: "Emil" }, { first: "Max", last: "Mustermann" }, { first: "Roman", last: "Tisch" },]);
const mappedModel = new MapModel(model, (data) => data.last + ", " + data.first);
// prints "Emil, Hans"console.log(mappedModel.rowData(0));Since a MapModel shares row change notifications with its source model, modifications made to the underlying model (for example through ArrayModel.setRowData) are reflected automatically.
Note that “sharing row change notifications” means a MapModel literally reuses its source model’s underlying notification channel — it does not have an independent one. As a consequence, calling MapModel.reset notifies every view bound to that channel, including views bound directly to the source model and views bound to any other MapModel wrapping the same source model instance, not just views bound to this particular MapModel. Only rely on this sharing behavior when the source model is not otherwise displayed on its own or wrapped by another MapModel.
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new MapModel<
T,U>(sourceModel,mapFunction):MapModel<T,U>
Defined in: api/node/typescript/models.ts:592 ↗
Constructs a new MapModel that provides a mapped view on the given
sourceModel by applying mapFunction on each of its rows.
Parameters
Section titled “Parameters”sourceModel
Section titled “sourceModel”Model<T>
the wrapped model.
mapFunction
Section titled “mapFunction”(data) => U
maps the data from T to U.
Returns
Section titled “Returns”MapModel<T, U>
Overrides
Section titled “Overrides”Model<U>.constructor
Properties
Section titled “Properties”sourceModel
Section titled “sourceModel”
readonlysourceModel:Model<T>
Defined in: api/node/typescript/models.ts:583 ↗
The source model that this MapModel maps rows from.
Methods
Section titled “Methods”[iterator]()
Section titled “[iterator]()”[iterator]():
Iterator<U>
Defined in: api/node/typescript/models.ts:196 ↗
Returns
Section titled “Returns”Iterator<U>
Inherited from
Section titled “Inherited from”filter()
Section titled “filter()”filter(
filterFunction):FilterModel<U>
Defined in: api/node/typescript/models.ts:118 ↗
Returns a new Model that only contains the rows of this model for which
filterFunction returns true.
Parameters
Section titled “Parameters”filterFunction
Section titled “filterFunction”(data) => boolean
returns true if a row should be visible.
Returns
Section titled “Returns”FilterModel<U>
a new FilterModel that wraps the current model.
Inherited from
Section titled “Inherited from”insertRow()
Section titled “insertRow()”insertRow(
_index,_data):void
Defined in: api/node/typescript/models.ts:190 ↗
Implementations of this function must add a row at the specified index, pushing all next rows to the right.
Parameters
Section titled “Parameters”_index
Section titled “_index”number
index of the row to insert.
U
new data item to store in a new row.
Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”map<
U>(mapFunction):MapModel<U,U>
Defined in: api/node/typescript/models.ts:108 ↗
Returns a new Model where all elements are mapped by the function mapFunction.
Type Parameters
Section titled “Type Parameters”U
Parameters
Section titled “Parameters”mapFunction
Section titled “mapFunction”(data) => U
maps the data from T to U.
Returns
Section titled “Returns”MapModel<U, U>
a new MapModel that wraps the current model.
Inherited from
Section titled “Inherited from”pushRow()
Section titled “pushRow()”pushRow(
_data):void
Defined in: api/node/typescript/models.ts:168 ↗
Implementations of this function must add a line to the model with the provided data.
Parameters
Section titled “Parameters”U
new data item to store in a new row.
Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”removeRow()
Section titled “removeRow()”removeRow(
_index):void
Defined in: api/node/typescript/models.ts:178 ↗
Implementations of this function must remove the row at the specified index.
Parameters
Section titled “Parameters”_index
Section titled “_index”number
index of the row to remove.
Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”reset()
Section titled “reset()”reset():
void
Defined in: api/node/typescript/models.ts:629 ↗
Notifies the run-time that the mapped view has changed. Call this if the map function’s result depends on state external to the source model and that state has changed, so that the mapped view reflects the current data.
Since MapModel shares its notification channel with the source model (see the class documentation), this also triggers a full reload of any other view bound to the same source model instance, including views bound to the source model directly or to a sibling MapModel.
Returns
Section titled “Returns”void
reverse()
Section titled “reverse()”reverse():
ReverseModel<U>
Defined in: api/node/typescript/models.ts:137 ↗
Returns a new Model with the same rows as this model, in reverse order.
Returns
Section titled “Returns”ReverseModel<U>
a new ReverseModel that wraps the current model.
Inherited from
Section titled “Inherited from”rowCount()
Section titled “rowCount()”rowCount():
number
Defined in: api/node/typescript/models.ts:601 ↗
Returns the number of entries in the model.
Returns
Section titled “Returns”number
Overrides
Section titled “Overrides”rowData()
Section titled “rowData()”rowData(
row):U|undefined
Defined in: api/node/typescript/models.ts:610 ↗
Returns the data at the specified row.
Parameters
Section titled “Parameters”number
index in range 0..(rowCount() - 1).
Returns
Section titled “Returns”U | undefined
undefined if row is out of range otherwise the data.
Overrides
Section titled “Overrides”setRowData()
Section titled “setRowData()”setRowData(
_row,_data):void
Defined in: api/node/typescript/models.ts:158 ↗
Implementations of this function must store the provided data parameter in the model at the specified row.
Parameters
Section titled “Parameters”number
index in range 0..(rowCount() - 1).
U
new data item to store on the given row index
Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”sort()
Section titled “sort()”sort(
compareFunction):SortModel<U>
Defined in: api/node/typescript/models.ts:129 ↗
Returns a new Model with the same rows as this model, ordered according to
compareFunction.
Parameters
Section titled “Parameters”compareFunction
Section titled “compareFunction”(a, b) => number
compares two rows the same way the callback passed to Array.prototype.sort does.
Returns
Section titled “Returns”SortModel<U>
a new SortModel that wraps the current model.
Inherited from
Section titled “Inherited from”© 2026 SixtyFPS GmbH