I have a map as my property.
Key - String, Value - Complex object
The map will be initialized during runtime using contents from a json file.
I want to read the json file only once at the beginning and initialize the map.
I will then add/ update the map. During every update to the map, I will write to the json file.
I want to make sure that I get the updated map every single time I use it.
Kindly suggest if Kotlin’s backing properties will be useful for my use case.
If not, kindly suggest an approach that I can follow.
I am able to parse this json to the map.
I am looking at ways on how this map can be initialized only once for the kotlin class’s instance and then be reused (instead of parsing the json again).
In that case, I think a property delegate that you initialize with the read value and that then writes on setValue operations (or queues the write, depending on your setup) should work for you