Skip to content

Add an @Entry macro for easier creation of custom Environment properties #11

Description

@jverkoey

Apple's documentation on the macro: https://developer.apple.com/documentation/swiftui/entry()

Rather than have to write something like this:

struct PathEnvironmentKey: EnvironmentKey {
  static let defaultValue: String = "/"
}

extension EnvironmentValues {
  var path: String {
    get { self[PathEnvironmentKey.self] }
    set { self[PathEnvironmentKey.self] = newValue }
  }
}

We'd be able to simply do this instead:

extension EnvironmentValues {
  @Entry var path: String = "/"
}

Will require learning how to create a Swift macro.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions