Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TCA101: Combine Publisher → Effect #20

Open
Taehyeon-Kim opened this issue Nov 26, 2023 · 0 comments
Open

TCA101: Combine Publisher → Effect #20

Taehyeon-Kim opened this issue Nov 26, 2023 · 0 comments
Labels
Milestone

Comments

@Taehyeon-Kim
Copy link
Owner

struct SomeClient {
  var fetchNumber: () async -> Int
}

//: Before
extension SomeClient: DependencyKey {
  static let liveValue = Self(fetchNumber: { _ in
    let number = ...
    Just(number).eraseToEffect() 
  })
}

//: After
extension SomeClient: DependencyKey {
  static let liveValue = Self(fetchNumber: { _ in
    Effect.publisher { Just(number) }
  })
}
  • Combine Publisher를 Effect로 Wrapping해서 사용하고 싶다면 publisher 메서드를 사용하면 된다.

Links:

@Taehyeon-Kim Taehyeon-Kim added this to the Snippets milestone Nov 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant