bisq-network / bisq-mobile

1 stars 4 forks source link

Shared Repositories: Multiplatform Settings #39

Open rodvar opened 1 week ago

rodvar commented 1 week ago

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:

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

nis-ship-it commented 1 week ago

Assign that to me

rodvar commented 1 week ago

@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 :ok_hand:

// 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? :)

rodvar commented 1 week ago

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

nis-ship-it commented 4 days ago

@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 commented 4 days ago

@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..?

nis-ship-it commented 3 days ago

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

rodvar commented 2 days ago

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

nis-ship-it commented 1 day ago

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

rodvar commented 1 day ago

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