A Kotlin Multiplatform library for building network-resilient applications
Find a file
Matt Ramotar 4f34a8b017
Update pull_request_template.md (#590)
Signed-off-by: Matt Ramotar <mramotar@dropbox.com>
2023-12-15 11:32:46 -05:00
.github Introduce Fallback Mechanisms (#545) 2023-05-08 18:18:37 -04:00
cache Migrate to version catalogs (#561) 2023-07-05 18:31:37 -04:00
gradle Prepare next version development version (#575) 2023-08-12 16:13:01 -04:00
Images Clean Up (#499) 2023-01-16 16:31:12 -05:00
multicast Migrate to version catalogs (#561) 2023-07-05 18:31:37 -04:00
rx2 Migrate to version catalogs (#561) 2023-07-05 18:31:37 -04:00
store Update CONTRIBUTING.md (#589) 2023-12-15 11:32:14 -05:00
.codecov.yml [Store5] Target Android, iOS, JVM, JS (#493) 2023-01-16 16:31:12 -05:00
.gitignore [Store5] Target Android, iOS, JVM, JS (#493) 2023-01-16 16:31:12 -05:00
build.gradle.kts Migrate to version catalogs (#561) 2023-07-05 18:31:37 -04:00
CHANGELOG.md Prepare for release 5.0.0 (#576) 2023-09-14 12:33:26 -04:00
CODE_OF_CONDUCT.md Create CODE_OF_CONDUCT.md 2017-07-24 14:12:01 -04:00
CONTRIBUTING.md Update CONTRIBUTING.md (#589) 2023-12-15 11:32:14 -05:00
gradle.properties Prepare for release 5.0.0 (#576) 2023-09-14 12:33:26 -04:00
gradlew [Store5] Target Android, iOS, JVM, JS (#493) 2023-01-16 16:31:12 -05:00
gradlew.bat [Store5] Target Android, iOS, JVM, JS (#493) 2023-01-16 16:31:12 -05:00
LICENSE Update license to include Dropbox copyright (#7) 2019-12-07 00:51:17 +01:00
pull_request_template.md Update pull_request_template.md (#590) 2023-12-15 11:32:46 -05:00
README.md Update README.md 2023-10-07 14:38:51 -04:00
RELEASING.md Release 5.0.0-alpha04 (#521) 2023-02-24 20:01:42 -05:00
settings.gradle Support Rx2 (#531) 2023-04-24 16:54:26 -04:00

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

Note

AtomicFU is required (#503)

Android

implementation "org.mobilenativefoundation.store:store5:5.0.0"
implementation "org.jetbrains.kotlinx:atomicfu:0.18.5"

Multiplatform (Common, JVM, Native, JS)

commonMain {
  dependencies {
    implementation("org.mobilenativefoundation.store:store5:5.0.0")
    implementation("org.jetbrains.kotlinx:atomicfu:0.18.5")
  }
}

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) 2022 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.