I am currently in the middle of Swift 3 migration, and I just ran into a problem with the fact that onCellUnHighlight is now gone.
In my code, I would previously react to the UnHighlight event of a TextRow to trigger an API call (to update that String on the server). However, it seems that only onCellHighlightChanged is available now, but I do not seem to understand how we can get the type of "change" (i.e. highlight or unhighlight).
Here is the code I previously used in Swift 2 with the Eureka Swift 2 branch:
TextRow(DEVICE_NAME_TAG) { row in
row.title = "Name"
row.value = device?.name
row.placeholder = "Your Device's Name"
}.onCellUnHighlight({ cell, row in
self.deviceNameFieldChanged(row.value ?? "")
}).onCellHighlight({ _, _ in })
Now, I know I can just check if the value changed before triggering the API call made by deviceNameFieldChanged() (which I do) but I wanted to know if there was a way to know which highlight event was triggered (basicly, reproduce the old behavior)?
Thanks
Hi @Laptopmini,
Every row has a new boolean property isHighlighted so you should implement onCellHighlightChanged and within the closure code check the row.isHighlighted value.
Therefore the right migration code is...
.onCellHighlightChanged{ cell, row [weak self] in
if !row.isHighlighted {
self?.deviceNameFieldChanged(row.value ?? "")
}
}
Hope it helps.
Thanks!
Most helpful comment
Hi @Laptopmini,
Every row has a new boolean property
isHighlightedso you should implementonCellHighlightChangedand within the closure code check therow.isHighlightedvalue.Therefore the right migration code is...
Hope it helps.