Skip to content

Instantly share code, notes, and snippets.

@steveriggins
Created November 16, 2021 03:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save steveriggins/36a6c5715a09f3ebbf69b9d8d4b51f95 to your computer and use it in GitHub Desktop.
Save steveriggins/36a6c5715a09f3ebbf69b9d8d4b51f95 to your computer and use it in GitHub Desktop.
import Combine
class Foo {
var blurValuePublisher: AnyPublisher<Float, Never> {
_blurValuePublisher.eraseToAnyPublisher()
}
private var _blurValuePublisher: CurrentValueSubject<Float, Never>
init() {
_blurValuePublisher = CurrentValueSubject<Float, Never>(12.0)
}
func doStuff(_ stuff: Float) {
_blurValuePublisher.send(50.3)
}
}
class Bar {
init() {
let f = Foo()
f.blurValuePublisher
.sink { value in
print(value)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment