Last active
March 6, 2016 01:03
-
-
Save bbarker/563a5f6ebc3fe7473293 to your computer and use it in GitHub Desktop.
Mutable reactive maps being mapped to each other
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Use the following instead: