Skip to content

A Kotlin Multiplatform solution for working with data. Whether you’re building alone or with a team of thousands, Store can help

License

Notifications You must be signed in to change notification settings

MobileNativeFoundation/Store

Folders and files

NameName
Last commit message
Last commit date

Latest commit

83e5f8d · Jul 7, 2024
Jul 7, 2024
Jan 16, 2023
Jul 7, 2024
Jun 29, 2024
Jul 7, 2024
Jul 7, 2024
Jul 7, 2024
Jul 7, 2024
Jul 7, 2024
Jul 7, 2024
Jul 7, 2024
Jan 16, 2023
Jun 29, 2024
Sep 14, 2023
Jul 24, 2017
Dec 15, 2023
Dec 6, 2019
Jul 7, 2024
Feb 25, 2023
Jul 7, 2024
Jul 7, 2024
Feb 28, 2024
Jun 29, 2024
Dec 15, 2023
Jun 29, 2024

Repository files navigation

Store5

codecov

Full documentation can be found on our website!

Join our official Slack on kotlinlang!

Concepts

  • Store is a typed repository that returns a flow of Data /Loading /Error from local and network data sources
  • MutableStore is a mutable repository implementation that allows create (C), read (R), update (U), and delete (D) operations for local and network resources
  • SourceOfTruth persists items
  • Fetcher defines how data will be fetched over network
  • Updater defines how local changes will be pushed to network
  • Bookkeeper tracks metadata of local changes and records synchronization failures
  • Validator returns whether an item is valid
  • Converter converts items between Network /Local /Output representations

Including Store In Your Project

Android

implementation "org.mobilenativefoundation.store:store5:5.1.0-alpha04"

Multiplatform (Common, JVM, Native, JS)

commonMain {
  dependencies {
    implementation("org.mobilenativefoundation.store:store5:5.1.0-alpha04")
  }
}

Getting Started

Building Your First Store

StoreBuilder
  .from<Key, Network, Output, Local>(fetcher, sourceOfTruth)
  .converter(converter)
  .validator(validator)
  .build(updater, bookkeeper)

Creating

Request
store.write(
  request = StoreWriteRequest.of<Key, Output, Response>(
    key = key,
    value = value
  )
)
Response
1. StoreWriteResponse.Success.Typed<Response>(response)

Reading

Request
store.stream<Response>(request = StoreReadRequest.cached(key, refresh = false))
Response
1. StoreReadResponse.Data(value, origin = StoreReadResponseOrigin.Cache)

Updating

Request
store.write(
  request = StoreWriteRequest.of<Key, Output, Response>(
    key = key,
    value = newValue
  )
)
Response
1. StoreWriteResponse.Success.Typed<Response>(response)

Deleting

Request
store.clear(key)

License

Copyright (c) 2024 Mobile Native Foundation.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.