TilesEditor

interface TilesEditor

Mutation surface a screen's TilesManager exposes for editing its own live tile tree by id — the collaborator behind dev.catbit.mosaic.client.ui.sdui.foundation.events.EventRunningScope.tilesEditor, and in turn behind the server DSL's AddTiles, RemoveTiles, ReplaceTiles, WipeTiles, UpdateTiles, CheckIfTileContainsChildren and GetTileChildrenCount events.

Every mutating method returns Result<Unit> rather than throwing directly, and rather than returning nothing: a call addressed to an id that doesn't currently exist on this screen fails the Result (wrapping a TileNotFoundException) instead of crashing the event chain that issued it, letting the runner that called it decide how to react (typically by firing its own onFailure). Every method that succeeds also triggers a state update, causing the affected part of the tree to recompose.

Inheritors

Functions

Link copied to clipboard
abstract fun addTile(tileSchema: TileSchema, where: InsertionPosition = InsertionPosition.End): Result<Unit>

Inserts tileSchema as a new top-level child of the screen's own root tile.

abstract fun addTile(tileSchema: TileSchema, groupingTileId: String, where: InsertionPosition = InsertionPosition.End): Result<Unit>

Inserts tileSchema as a new child of the container tile identified by groupingTileId, wherever that container currently is in the tree.

Link copied to clipboard
abstract fun addTiles(tileSchemas: List<TileSchema>, where: InsertionPosition = InsertionPosition.End): Result<Unit>

Same as addTile, for several tiles inserted together at the same position, preserving tileSchemas' own order.

abstract fun addTiles(tileSchemas: List<TileSchema>, groupingTileId: String, where: InsertionPosition = InsertionPosition.End): Result<Unit>

Same as the groupingTileId overload of addTile, for several tiles inserted together.

Link copied to clipboard
abstract fun checkIfTileHasChildren(groupingTileId: String, childrenIds: List<String>): Boolean

Whether every id in childrenIds is currently a direct child of the container tile identified by groupingTileId — the mechanism behind CheckIfTileContainsChildren. Unlike the other methods on this interface, this doesn't fail when groupingTileId isn't found; it simply returns false.

Link copied to clipboard
abstract fun getTileChildrenCount(groupingTileId: String): Int?

Number of direct children currently under the container tile identified by groupingTileId — the mechanism behind GetTileChildrenCount.

Link copied to clipboard
abstract fun removeTile(tileId: String): Result<Unit>

Removes the top-level root tile whose id equals tileId.

abstract fun removeTile(tileId: String, groupingTileId: String): Result<Unit>

Removes the child whose id equals tileId from the container tile identified by groupingTileId.

Link copied to clipboard
abstract fun removeTiles(tileIds: List<String>): Result<Unit>

Removes every top-level root tile whose id is in tileIds.

abstract fun removeTiles(tileIds: List<String>, groupingTileId: String): Result<Unit>

Removes every child whose id is in tileIds from the container tile identified by groupingTileId.

Link copied to clipboard
abstract fun replaceTiles(tileSchemas: List<TileSchema>): Result<Unit>

Replaces every top-level root tile with tileSchemas — the current root children are wiped first, then tileSchemas is added in full.

abstract fun replaceTiles(tileSchemas: List<TileSchema>, groupingTileId: String): Result<Unit>

Replaces every child of the container tile identified by groupingTileId with tileSchemas — that container's current children are wiped first, then tileSchemas is added in full.

Link copied to clipboard
abstract fun updateTile(tileId: String, updateData: Map<String, Any?>): Result<Unit>

Applies updateData as a shallow JSON-patch merge onto the tile identified by tileId — see dev.catbit.mosaic.client.ui.sdui.foundation.tiles.holder.tile.TileHolder.update for exactly how the merge (and the special handling of a "style" patch) works. The lookup also searches inside event holders' own nested tiles, not just the plain tile tree.

Link copied to clipboard
abstract fun wipeTiles(groupingTileId: String): Result<Unit>

Removes every child of the container tile identified by groupingTileId, leaving it empty.