Giter Club home page Giter Club logo

store's Introduction

Store5

codecov

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

Note

AtomicFU is required (#503)

Android

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

Multiplatform (Common, JVM, Native, JS)

commonMain {
  dependencies {
    implementation("org.mobilenativefoundation.store:store5:5.0.0-alpha06")
    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.

store's People

Contributors

aclassen avatar alexio avatar aminelaadhari avatar brianplummer avatar changusmc avatar chris-mitchell avatar clhols avatar cybo42 avatar dependabot[bot] avatar digitalbuddha avatar dyjparker avatar eyalgu avatar fabiocollini avatar handstandsam avatar jeremy-techson avatar jogan avatar kevcron avatar maksim-m avatar matt-ramotar avatar mezpahlan avatar michaldrabik avatar nightlynexus avatar paulwoitaschek avatar pavlospt avatar ramonaharrison avatar stoyicker avatar tasomaniac avatar wclausen avatar ychescale9 avatar yigit avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.