bisq-network/bisq-mobile

Shared Repositories: Multiplatform Settings

Closed this issue ยท 11 comments

For the shared repositories architecture we will need a at least one way of persisting data. We are unsure if we would need complex data structure, but definitely and easy and fast key-value store will be needed at least for settings.

This issue goals are:

  • Analyse MultiSettings lib for KMP --> https://github.com/russhwolf/multiplatform-settings which looks like the best candidate for a KMP compose project
  • add a shared/data module (or reuse shared/domain probably better, we use a subpackage for data there) and integrate the needed dependencies
  • if needed, provide a wrapper of the lib to make it easy to save key/value (probably not but just mentioning)
  • provide the necessary Koin repository to share this dependency
  • provide an example of usage reading/saving a setting
  • test that it works in the 3 apps.

This dependency will be injected in some of our repositories, best candidate will be SettingsRepository (TBC)

Assign that to me

@nis-ship-it I'm thinking for the work I'm doing here , if your PR includes that the implementation you are building for Multiplatforms Settings implements an interface like the following it would be ideal ๐Ÿ‘Œ

// ignore the BaseModel definition I'm working on that in my branch
interface PersistenceSource<T: BaseModel> {
    suspend fun save(item: T)
    suspend fun saveAll(items: List<T>)
    suspend fun get(): T?
    suspend fun getAll(): List<T>
    suspend fun delete(item: T)
    suspend fun deleteAll()
}

Let me know how does that sound? :)

I've just implemented the first bunch of definitions, trying to be proactive and share with you so we collide the less possible when merging

@rodvar I'm not getting this part, I was thinking we using the library to store something super small? Why are you having it under shared common module? Plus I don't know about "Shared Repositories" could you elaborate on it?

@rodvar I'm not getting this part, I was thinking we using the library to store something super small? Why are you having it under shared common module? Plus I don't know about "Shared Repositories" could you elaborate on it?

@nis-ship-it As per our architecture design , all the data is saved using repositories. Those are implemented in the shared domain module (hence why we call them "shared repositories". They will be used both, by the presentation layer and by the services layer (more on this coming soon, I'm updating the README this weekend)

We might have more persistence implementation, the one you are implementing is a multiplaform way of storing small key-value data. Makes sense?

So if you just do a class that implements that interface, and uses KMP multiplatform settings we will have available the first way of persistance for the 3 apps. Let me know if this makes sense..?

At the moment, I'm able to use the instance easily on android side (node + client) however same is not for iOS since it's not able to get definition of type "Settings".

Tried another way which was to use Provider but then end getting error on

Function doesn't have or inherit @Throws annotation and thus exception isn't propagated from Kotlin to Objective-C/Swift as NSError.

So, tried that out even but not working

@nis-ship-it just contributed to your PR, hope it helps. Feel free to do whatever works best for you from it

I had done something similar to wrap the object, however I keep doing things that we need to do something on iOS however forgot that's it a kmp library and it does manage that... Sorry about that however still need to learn more on structure of kmp app

no problem @nis-ship-it we are all learning here! This issue is not top priority at the moment so you have plenty of time. Let me know if I can help in any other way

I'll take over this one this week as discuss with @nis-ship-it

done with the above