Andy Victors
05/21/2019, 6:28 AMAtomicReference
is not available for me in common code? According to documentation is should be. Kotlin '1.3.30'svyatoslav.scherbina
05/21/2019, 6:42 AMAndy Victors
05/21/2019, 6:45 AMAndy Victors
05/21/2019, 6:46 AMsvyatoslav.scherbina
05/21/2019, 6:48 AMval
instead of object
.Andy Victors
05/21/2019, 6:48 AMobject RegistrationManager{
var registrations: arrayOf()
}
Andy Victors
05/21/2019, 6:51 AMAndy Victors
05/21/2019, 6:52 AMAndy Victors
05/21/2019, 6:54 AMcommon
Andy Victors
05/21/2019, 6:57 AMsvyatoslav.scherbina
05/21/2019, 7:13 AMval
suitable for you?Andy Victors
05/21/2019, 7:17 AMval GlobalRegistrationManager = RegistrationManager()
class RegistrationManager{
var registrations: arrayOf()
}
Then, still, on order to have no side effects I need to make sure calling it from main thread in all platform code. I just expected more elegant solution from KotlinAndy Victors
05/21/2019, 7:28 AMsvyatoslav.scherbina
05/21/2019, 7:30 AMIs it possible to define this val in the common code?
You mean like this:Yes. Alternatively consider using https://github.com/touchlab/Stately
Andy Victors
05/21/2019, 8:15 AMolonho
05/21/2019, 9:00 AMAndy Victors
05/21/2019, 9:13 AMolonho
05/21/2019, 9:31 AMkpgalligan
05/21/2019, 12:46 PMAndy Victors
05/21/2019, 12:50 PMkpgalligan
05/21/2019, 12:57 PMkpgalligan
05/21/2019, 12:57 PMkpgalligan
05/21/2019, 12:58 PMkpgalligan
05/21/2019, 1:00 PMAndy Victors
05/21/2019, 1:38 PMkpgalligan
05/21/2019, 1:50 PMkpgalligan
05/21/2019, 1:53 PMAndy Victors
05/23/2019, 7:20 AMval fetchers:MutableList<DataSourceFetcher> = frozenCopyOnWriteList<DataSourceFetcher>()
, will the list items be frozen? Because the mutability is working now but I guess I get an exception while trying to modify an item.Andy Victors
05/23/2019, 7:26 AMAndy Victors
05/23/2019, 7:32 AMkpgalligan
05/23/2019, 2:07 PMAndy Victors
05/23/2019, 2:24 PMAndy Victors
05/23/2019, 2:24 PMDataFetcher
and `DataStorage`classes, for getting data from remote to storing it, well, into the storage object
• The list of DataFetchers
is global, but mutable using `frozenCopyOnWriteList<>`from Stately
lib => therefore all Fetchers are frozen
• To tell a Fetcher which storage he needs to store the date into, I pass the Storage object in constructor.
• PROBLEM: since Storage is then in the same object graph as the Fetcher, Storage becomes frozen. But it's counter-goal for a storage object.
There should be a pattern for that, isn't it?Arkadii Ivanov
05/24/2019, 5:36 PMAndy Victors
05/24/2019, 6:03 PMfrozenCopyOnWriteList<>
does, because my singleton is in common code, so AtomicReference is not accessible. Using AtomicReference requires enclosed object to be frozen which leads exactly to the problem I point above 😕Arkadii Ivanov
05/24/2019, 6:08 PMArkadii Ivanov
05/24/2019, 6:12 PMArkadii Ivanov
05/24/2019, 6:14 PMkpgalligan
05/24/2019, 6:14 PMkpgalligan
05/24/2019, 6:15 PMArkadii Ivanov
05/24/2019, 6:19 PMkpgalligan
05/24/2019, 6:20 PMArkadii Ivanov
05/24/2019, 6:20 PM