{"repo":"omaralbeik/Stores","free":true,"listed":false,"github":"https://github.com/omaralbeik/Stores","clone":"git clone https://github.com/omaralbeik/Stores.git","description":"Typed key-value storage solution to store Codable types in various persistence layers with few lines of code!","language":"Swift","stars":140,"topics":["coredata","filesystem","spm","swift","userdefaults","cache","db","keychain","keyvaluestore","store"],"license":"MIT","category":"mobile-apps","readme_excerpt":"🗂 Stores A typed key-value storage solution to store Codable types in various persistence layers like User Defaults, File System, Core Data, Keychain, and more with a few lines of code! Features - [x] macOS Catalina+, iOS 13+, tvOS 13+, watchOS 6+, any Linux supporting Swift 5.4+. - [x] Store any Codable type. - [x] Single API with implementations using User Default, file system, Core Data, Keychain, and fakes for testing. - [x] Thread-safe implementations. - [x] Swappable implementations with a type-erased store. - [x] Modular library, add all, or only what you need. --- Motivation When working on an app that uses the composable architecture, I fell in love with how reducers use an environment type that holds any dependencies the feature needs, such as API clients, analytics clients, and more. Stores tries to abstract the concept of a store and provide various implementations that can be injected in such environment and swapped easily when running tests or based on a remote flag. It all boils down to the two protocols SingleObjectStore and MultiObjectStore defined in the Blueprints layer, which provide the abstract concepts of stores that can store a single or multiple objects of a generic Codable type. The two protocols are then implemented in the different modules as explained in the chart below: --- Usage Let's say you have a User struct defined as below: Here's how you store it using Stores: 1. Conform to Identifiable This is required to make the store associate an obje","default_branch":null,"files":null,"tree":[],"storefront":"/r/omaralbeik","claimed":false,"request_supported":{"post":"https://gitbuyer.com/r/omaralbeik/Stores/request-supported","requests":0},"note":"indexed from public GitHub; nothing is for sale on this page. Clone it from GitHub. Paid listings live at /search."}