Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/mihaelisaev/state

Swift @State
https://github.com/mihaelisaev/state

Last synced: 4 months ago
JSON representation

Swift @State

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)
```