{"id":13338730,"url":"https://github.com/moriturus/StoredIn","last_synced_at":"2025-03-11T10:31:51.156Z","repository":{"id":40758404,"uuid":"498031020","full_name":"moriturus/StoredIn","owner":"moriturus","description":"A Property Wrapper to store a value anywhere.","archived":false,"fork":false,"pushed_at":"2022-06-27T17:54:23.000Z","size":9,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-10-23T22:18:39.488Z","etag":null,"topics":["ios","ipados","macos","swift","tvos","watchos"],"latest_commit_sha":null,"homepage":"","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/moriturus.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-05-30T17:06:33.000Z","updated_at":"2023-03-05T05:06:37.000Z","dependencies_parsed_at":"2022-07-29T09:19:06.523Z","dependency_job_id":null,"html_url":"https://github.com/moriturus/StoredIn","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/moriturus%2FStoredIn","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/moriturus%2FStoredIn/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/moriturus%2FStoredIn/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/moriturus%2FStoredIn/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/moriturus","download_url":"https://codeload.github.com/moriturus/StoredIn/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243015441,"owners_count":20222082,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ios","ipados","macos","swift","tvos","watchos"],"created_at":"2024-07-29T19:17:08.880Z","updated_at":"2025-03-11T10:31:50.715Z","avatar_url":"https://github.com/moriturus.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"# StoredIn\n\n[![Swift Package Manager compatible](https://img.shields.io/badge/Swift%20Package%20Manager-compatible-brightgreen.svg)](https://github.com/apple/swift-package-manager)\n\n`StoredIn` is a simple property wrapper library to store any value in anywhere.\n\n## Installation\n\nPlease use the `Swift Package Manager`.\n\n```swift\ndependencies: [\n    .package(url: \"https://github.com/moriturus/StoredIn.git\", .upToNextMajor(from: \"1.0.0\"))\n]\n```\n\n## Usage\n\n```swift\nimport StoredIn\n\n// implement the `Store` where your data are saved.\nfinal class SharedDictionary: Store {\n    typealias Key = String\n    \n    var inner: [String: Any] = [:]\n    \n    func containsValue(forKey key: String) -\u003e Bool {\n        self.inner[key] != nil\n    }\n    \n    func value\u003cS\u003e(forKey key: String) -\u003e S? where S : Storable {\n        self.inner[key] as? S\n    }\n    \n    func set\u003cS\u003e(value: S, forKey key: String) where S : Storable {\n        self.inner[key] = value\n    }\n}\n\nlet sharedDictionary = SharedDictionary()\n\nstruct Foo {\n    @StoredIn(store: sharedDictionary, key: \"key\", default: 0, strategy: .default)\n    var value: Int\n}\n\nvar foo = Foo()\nlet x = foo.value // x == 0\nfoo.value = 1\nsharedDictionary.inner[\"key\"] as? Int == foo.value // true\n```\n\n## Strategy\n\n- `default`\n    - The default strategy. You can change stored value as many times as you need.\n- `once`\n    - You can store a value only once.\n\n## License\n\nThis software is released under the MIT License.  \nSee LICENSE file for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmoriturus%2FStoredIn","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmoriturus%2FStoredIn","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmoriturus%2FStoredIn/lists"}