kluck
06/19/2019, 7:07 AMclass InMemoryStorePersistentSource : IStorePersistentSource {
private var store: IO<Option<Store>> = IO { None }
override fun getCurrentStore(): IO<Option<Store>> = store
override fun persistCurrentStore(store: Option<Store>): IO<Unit> = IO { this.store = IO { store } }
}raulraja
06/19/2019, 8:42 AMinterface IStorePersistentSource {
fun getCurrentStore(): IO<Option<Store>>
fun persistCurrentStore(store: Option<Store>): IO<Unit>
}
It is fine since the effect of replacing the store is encapsulated in the IO constructor and you can still replace the interpreter in tests.
No need for IO { None } because it’s inefficient since that constructor is lazy and you already have a computed pure value. That should be instead IO.just(None).kluck
06/19/2019, 8:53 AMIO {} and IO.just(). Thanks!kluck
06/19/2019, 8:57 AMpakoito
06/19/2019, 9:01 AM