https://github.com/ikesyo/swift-with-previous
A Swift property wrapper which stores the previous value
https://github.com/ikesyo/swift-with-previous
Last synced: over 1 year ago
JSON representation
A Swift property wrapper which stores the previous value
- Host: GitHub
- URL: https://github.com/ikesyo/swift-with-previous
- Owner: ikesyo
- License: mit
- Created: 2021-09-06T23:42:37.000Z (almost 5 years ago)
- Default Branch: main
- Last Pushed: 2021-09-07T06:55:12.000Z (almost 5 years ago)
- Last Synced: 2025-03-10T18:04:53.350Z (over 1 year ago)
- Language: Swift
- Size: 3.91 KB
- Stars: 4
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# swift-with-previous
A Swift property wrapper which stores the previous value. The previous value can be get by the projected value `$propertyName`.
```swift
import XCTest
import WithPrevious
final class WithPreviousTests: XCTestCase {
@WithPrevious var value = 0
func testWithPreviousWrapper() {
XCTAssertEqual(value, 0)
XCTAssertNil($value)
value = 10
XCTAssertEqual(value, 10)
XCTAssertEqual($value, 0)
}
}
```
## License
MIT license. See [LICENSE](LICENSE) for details.