Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mihaelisaev/state
Swift @State
https://github.com/mihaelisaev/state
Last synced: 4 months ago
JSON representation
Swift @State
- Host: GitHub
- URL: https://github.com/mihaelisaev/state
- Owner: MihaelIsaev
- Created: 2020-04-26T14:12:30.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2020-04-26T14:24:27.000Z (almost 5 years ago)
- Last Synced: 2024-04-14T07:11:38.309Z (10 months ago)
- Language: Swift
- Size: 3.91 KB
- Stars: 7
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# State
A simple `@State` property wrapper.
You could declare any variable as `@State`
```swift
@State var connecting = false
```then you can listen for changes
```swift
connecting.listen { old, new in
print("connecting var changed from \(old) to \(new)")
}
// or
connecting.listen { new in
print("connecting var changed from to \(new)")
}
// or even
connecting.listen {
print("connecting var changed")
}
```
you can create a function with it
```swift
func test(_ state: State) {}
```
and you can pass it into that function
```swift
test($connecting)
```