mirror of
https://github.com/fxm90/GradientLoadingBar.git
synced 2026-04-17 12:17:30 +00:00
ed722cb70d
* added `Observable` pod as dependency for `GradientLoadingBar`
Observable is the easiest way to observe values in Swift.
How to
Create an Observable
var position = Observable(CGPoint.zero)
Add an observer
position.observe { p in
// handle new position
}
Change the value
position.value = p
Memory management
For a single observer you can store the returned Disposable to a variable
disposable = position.observe { p in
For multiple observers you can add the disposable to a Disposal variable
position.observe { }.add(to: &disposal)
And always weakify self when referencing self inside your observer
position.observe { [weak self] position in
Installation
CocoaPods
Observable is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod 'Observable'
Suggestions or feedback?
Feel free to create a pull request, open an issue or find me on Twitter.
