Skip to content

AliasBuilder

tgrapperon edited this page Aug 22, 2022 · 4 revisions

AliasBuilder

A type that is used to configure dependencies aliases when using the DerivedEnvironment property wrapper.

public struct AliasBuilder<Environment> where Environment: ComposableEnvironment 

Methods

alias(_:to:)

Add a new dependency alias to the builder

public func alias<Dependency>(
    _ dependency: WritableKeyPath<Dependencies, Dependency>,
    to default: WritableKeyPath<Dependencies, Dependency>
  ) -> Self 

You can chain calls to define multiple aliases:

builder
  .alias(\.main, to: \.mainQueue)
  .alias(\.uuid, to: \.idGenerator)
  

See the discussion at DependenciesAccessing.aliasing(:to:) for more information.

Parameters

  • dependency: The KeyPath of the aliased dependency in Dependencies
  • to: A KeyPath of another dependency in Dependencies that serves as a reference value.

alias(_:to:)

Add a new dependency alias to the builder

public func alias<Dependency>(
    _ dependency: WritableKeyPath<Dependencies, Dependency>,
    to default: WritableKeyPath<Dependencies, Dependency>
  ) -> Self 

You can chain calls to define multiple aliases:

builder
  .alias(\.main, to: \.mainQueue)
  .alias(\.uuid, to: \.idGenerator)
  

See the discussion at DependenciesAccessing.aliasing(:to:) for more information.

Parameters

  • dependency: The KeyPath of the aliased dependency in Dependencies
  • to: A KeyPath of another dependency in Dependencies that serves as a reference value.