Skip to content

ReverseModel

Defined in: api/node/typescript/models.ts:829

ReverseModel acts as an adapter model for a given source model by reversing all its rows. This means that the first row in the source model is the last row of this model, the second row is the second last, and so on.

Unlike FilterModel and SortModel, ReverseModel does not need to cache any state derived from the whole source model, so it always reflects the current row count and row data of the source model. However, since row insertions and removals on the source model are not automatically observed, call ReverseModel.reset after such a modification so that the run-time re-renders the reversed view. Modifications made through ReverseModel.setRowData are reflected automatically.

const source = new ArrayModel([1, 2, 3, 4, 5]);
const reversed = new ReverseModel(source);
// prints 5, 4, 3, 2, 1
for (const x of reversed) {
console.log(x);
}
js

T

new ReverseModel<T>(sourceModel): ReverseModel<T>

Defined in: api/node/typescript/models.ts:840

Constructs a new ReverseModel that provides a reversed view on the given sourceModel.

Model<T>

the wrapped model.

ReverseModel<T>

Model<T>.constructor

readonly sourceModel: Model<T>

Defined in: api/node/typescript/models.ts:833

The source model that this ReverseModel reverses rows from.

[iterator](): Iterator<T>

Defined in: api/node/typescript/models.ts:196

Iterator<T>

Model.[iterator]


filter(filterFunction): FilterModel<T>

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.

(data) => boolean

returns true if a row should be visible.

FilterModel<T>

a new FilterModel that wraps the current model.

Model.filter


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.

number

index of the row to insert.

T

new data item to store in a new row.

void

Model.insertRow


map<U>(mapFunction): MapModel<T, U>

Defined in: api/node/typescript/models.ts:108

Returns a new Model where all elements are mapped by the function mapFunction.

U

(data) => U

maps the data from T to U.

MapModel<T, U>

a new MapModel that wraps the current model.

Model.map


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.

T

new data item to store in a new row.

void

Model.pushRow


removeRow(_index): void

Defined in: api/node/typescript/models.ts:178

Implementations of this function must remove the row at the specified index.

number

index of the row to remove.

void

Model.removeRow


reset(): void

Defined in: api/node/typescript/models.ts:887

Notifies the run-time that the reversed view must be reloaded. Call this after modifying the source model directly (for example calling ArrayModel.push or ArrayModel.splice on the underlying source model), so that the reversed view reflects the current row count of the source model.

void


reverse(): ReverseModel<T>

Defined in: api/node/typescript/models.ts:137

Returns a new Model with the same rows as this model, in reverse order.

ReverseModel<T>

a new ReverseModel that wraps the current model.

Model.reverse


rowCount(): number

Defined in: api/node/typescript/models.ts:848

Returns the number of entries in the model.

number

Model.rowCount


rowData(row): T | undefined

Defined in: api/node/typescript/models.ts:857

Returns the data at the specified row.

number

index in range 0..(rowCount() - 1).

T | undefined

undefined if row is out of range otherwise the data.

Model.rowData


setRowData(row, data): void

Defined in: api/node/typescript/models.ts:871

Stores the given data in the source model at the row that corresponds to the given reversed row index, and notifies the run-time about the change.

number

index in range 0..(rowCount() - 1).

T

new data item to store on the given row index.

void

Model.setRowData


sort(compareFunction): SortModel<T>

Defined in: api/node/typescript/models.ts:129

Returns a new Model with the same rows as this model, ordered according to compareFunction.

(a, b) => number

compares two rows the same way the callback passed to Array.prototype.sort does.

SortModel<T>

a new SortModel that wraps the current model.

Model.sort


© 2026 SixtyFPS GmbH