Skip to content

Instantly share code, notes, and snippets.

@below
Last active February 27, 2020 18:27
Show Gist options
  • Select an option

  • Save below/2fa8f9f4d7840ae37be897065d9bcc36 to your computer and use it in GitHub Desktop.

Select an option

Save below/2fa8f9f4d7840ae37be897065d9bcc36 to your computer and use it in GitHub Desktop.
A simple combine sample. Good code? Could it be better?
class InOut: ObservableObject {
@Published var input = ""
@Published private (set) var output = "output"
private var publisher: AnyCancellable?
init() {
publisher = $input.map({
String($0.reversed())
}).assign(to: \.output, on: self)
}
}
@below

below commented Feb 27, 2020

Copy link
Copy Markdown
Author

Updated with some helpful input

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment