Swift Package Index


Swift @State


  • The latest stable release is 1.0.0. Released 9 months ago.
  • The last commit to master was 9 months ago.

Swift Version Compatibility

  • 1.0.0 and master
    5.3
    5.2
    5.1
    5.0
    4.2
Full build results

Platform Compatibility

  • 1.0.0 and master
    iOS
    macOS(Intel)
    macOS(ARM)
    Linux
    tvOS
    watchOS
Full build results

State

A simple @State property wrapper.

You could declare any variable as @State

@State var connecting = false

then you can listen for changes

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

func test(_ state: State<Bool>) {}

and you can pass it into that function

test($connecting)