Betül Necanlı
Nov 20, 2023

--

You are correct, localData is initialized with the value of SharedData.commonData when each instance is created, but it doesn't maintain a dynamic link to it. In the Monostate pattern, the idea is that multiple instances share the same data (in this case, commonData), and when you update it through one instance, all instances should reflect the change without needing to update each instance individually. You would indeed need to use a delegated property or a function to get the latest value.

--

--

Betül Necanlı
Betül Necanlı

Written by Betül Necanlı

Kotlin, Android Programming, Data Structures&Algorithms, Math. https://www.youtube.com/@betulnecanli

No responses yet