https://github.com/kizzycode/valueprovider-swift
This package defines an API for values managed by a value provider e.g. to interface on-disk values
https://github.com/kizzycode/valueprovider-swift
Last synced: about 2 months ago
JSON representation
This package defines an API for values managed by a value provider e.g. to interface on-disk values
- Host: GitHub
- URL: https://github.com/kizzycode/valueprovider-swift
- Owner: KizzyCode
- Created: 2020-08-17T01:35:51.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2020-11-28T02:00:19.000Z (over 4 years ago)
- Last Synced: 2025-02-06T04:44:16.618Z (3 months ago)
- Language: Swift
- Homepage:
- Size: 47.9 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE BSD 2-CLAUSE.md
Awesome Lists containing this project
README
# ValueProvider
This package defines an API for values managed by a value provider; e.g. to interface on-disk values.
## Example
```swift
/// A persistent counter example
struct Example {
/// Define a test directory (usually you do this once somewhere in your app)
static let testDir = FileManager.default.temporaryDirectory
.appendingPathComponent("de.KizzyCode.FilesystemValueProvider.Tests")
/// Define a provider (usually you do this once somewhere in your app)
static let provider = try! FilesystemValueProvider(basePath: Self.testDir)
/// The counter value
@Mapped(provider: Self.provider, for: "Example.counter", default: 0)
private var counter: Int
/// Does something with the counter value
public mutating func count() {
defer { self.counter += 1 }
print("Counter:", self.counter)
}
}// Do something with out example
var example = Example()
example.count()
```