A Kotlin Multiplatform library for building network-resilient applications
Find a file
Matt 728d0e5792
Clean Up (#499)
* Remove "Representation" from generics

Signed-off-by: mramotar <mramotar@dropbox.com>

* Remove "Representation" from generics

Signed-off-by: mramotar <mramotar@dropbox.com>

* Rename to Validator

Signed-off-by: mramotar <mramotar@dropbox.com>

* Add logo!

Signed-off-by: mramotar <mramotar@dropbox.com>

* Update README.md

Signed-off-by: mramotar <mramotar@dropbox.com>

* Format

Signed-off-by: mramotar <mramotar@dropbox.com>

* Update CI

Signed-off-by: Matt <mramotar@dropbox.com>

* Remove "Representation" from generics

Signed-off-by: mramotar <mramotar@dropbox.com>

* Remove "Representation" from generics

Signed-off-by: mramotar <mramotar@dropbox.com>

* Rename to Validator

Signed-off-by: mramotar <mramotar@dropbox.com>

* Add logo!

Signed-off-by: mramotar <mramotar@dropbox.com>

* Update README.md

Signed-off-by: mramotar <mramotar@dropbox.com>

* Format

Signed-off-by: mramotar <mramotar@dropbox.com>

* Rename generics

Signed-off-by: mramotar <mramotar@dropbox.com>

* Rename input to value

Signed-off-by: mramotar <mramotar@dropbox.com>

* Update README

Signed-off-by: mramotar <mramotar@dropbox.com>

* Update README

Signed-off-by: mramotar <mramotar@dropbox.com>

Signed-off-by: mramotar <mramotar@dropbox.com>
Signed-off-by: Matt <mramotar@dropbox.com>
2022-12-23 11:04:24 -08:00
.github Update CI 2022-12-21 19:14:54 -08:00
buildSrc Add Write + Conflict Resolution (#496) 2022-12-20 17:34:00 -08:00
cache Clean Up (#499) 2022-12-23 11:04:24 -08:00
gradle [Store5] Target Android, iOS, JVM, JS (#493) 2022-12-18 10:53:21 -05:00
Images Clean Up (#499) 2022-12-23 11:04:24 -08:00
multicast [Store5] Target Android, iOS, JVM, JS (#493) 2022-12-18 10:53:21 -05:00
store Clean Up (#499) 2022-12-23 11:04:24 -08:00
.codecov.yml [Store5] Target Android, iOS, JVM, JS (#493) 2022-12-18 10:53:21 -05:00
.gitignore [Store5] Target Android, iOS, JVM, JS (#493) 2022-12-18 10:53:21 -05:00
build.gradle.kts [Store5] Target Android, iOS, JVM, JS (#493) 2022-12-18 10:53:21 -05:00
CHANGELOG.md Add Write + Conflict Resolution (#496) 2022-12-20 17:34:00 -08:00
CODE_OF_CONDUCT.md Create CODE_OF_CONDUCT.md 2017-07-24 14:12:01 -04:00
CONTRIBUTING.md Start tracking API binary compatibility (#97) 2020-02-15 11:59:42 -05:00
gradle.properties Prepare next development version (#495) 2022-12-20 17:14:40 -08:00
gradlew [Store5] Target Android, iOS, JVM, JS (#493) 2022-12-18 10:53:21 -05:00
gradlew.bat [Store5] Target Android, iOS, JVM, JS (#493) 2022-12-18 10:53:21 -05:00
LICENSE Update license to include Dropbox copyright (#7) 2019-12-07 00:51:17 +01:00
pull_request_template.md Create pull_request_template.md 2019-12-07 00:49:00 +01:00
README.md Clean Up (#499) 2022-12-23 11:04:24 -08:00
RELEASING.md [Store5] Target Android, iOS, JVM, JS (#493) 2022-12-18 10:53:21 -05:00
settings.gradle [Store5] Target Android, iOS, JVM, JS (#493) 2022-12-18 10:53:21 -05:00

Store5

Full documentation can be found on our website!

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.0.0-alpha03"

Multiplatform (Common, JVM, Native, JS)

commonMain {
  dependencies {
    implementation("org.mobilenativefoundation.store:store5:5.0.0-alpha03")
  }
}

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.