Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Mutable reactive maps being mapped to each other
protected val controlMap: Dict[TableIndex, ControlTypes] = Dict()
protected val textInMap: Dict[TableIndex, String] = Dict()
protected val textMap: Dict[TableIndex, String] = Dict()
val controlToText = controlMap.changes.attach{
case delta: Dict.Delta.Insert[TableIndex, ControlTypes] =>
val te = implicitly[ControlTableEntry[ControlTypes, String]]
textMap(delta.key) = te.getEntry(delta.value)
case delta: Dict.Delta.Update[TableIndex, ControlTypes] =>
val te = implicitly[ControlTableEntry[ControlTypes, String]]
textMap(delta.key) = te.getEntry(delta.value)
case delta: Dict.Delta.Remove[TableIndex, ControlTypes] =>
textMap.removeIfExists(delta.key)
case delta: Dict.Delta.Clear[TableIndex, ControlTypes] =>
textMap.clear()
}
val textIntoText = textInMap.changes.attach{
case delta: Dict.Delta.Insert[TableIndex, String] =>
textMap(delta.key) = delta.value
case delta: Dict.Delta.Update[TableIndex, String] =>
textMap(delta.key) = delta.value
case delta: Dict.Delta.Remove[TableIndex, String] =>
textMap.removeIfExists(delta.key)
case delta: Dict.Delta.Clear[TableIndex, String] =>
textMap.clear()
}
@bbarker

This comment has been minimized.

Copy link
Owner Author

bbarker commented Mar 6, 2016

Use the following instead:

protected val textMap: Dict[TableIndex, String] =
    textInMap.map[String]((k,v) => v).buffer
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.