Skip to content

Documentation improvement for pathsΒ #149

@blackwiz4rd

Description

@blackwiz4rd

In

https://xxfast.github.io/KStore/using-platform-paths.html#defining-your-own-directories

it's not very clear how to specify the paths for platforms.
In particular it's not reported that you might want to create an interface in common code

interface KStoreDbIface {
    val user: KStore<UserV1>
    val settings: KStore<SettingsV1>
}

expect fun provideKStoreDb(): KStoreDbIface

which is then implmented by the platform code.
E.g. in Android, where context is passed (e.g. via Koin DI)

actual fun provideKStoreDb(): KStoreDbIface = KStoreDb(context)
class KStoreDb(context: Context) : KStoreDbIface {
    override val user: KStore<UserV1> = storeOf(
        file = Path("${context.filesDir}/user.json"),
        version = 1,
    )
    override val settings: KStore<SettingsV1> = storeOf(
        file = Path("${context.filesDir}/settings.json"),
        version = 1,
    )
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions