Skip to content

Instantly share code, notes, and snippets.

@dmcrodrigues
Last active November 8, 2017 07:42
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dmcrodrigues/5e77d00f375068afa9bf1600838ccbed to your computer and use it in GitHub Desktop.
Save dmcrodrigues/5e77d00f375068afa9bf1600838ccbed to your computer and use it in GitHub Desktop.
Observing an array using ReactiveCocoa
import ReactiveCocoa
let a: MutableProperty<[Int]> = MutableProperty([])
a.signal.observeNext { array in
print("Array did change: \(array)")
}
a.value.append(1)
a.value.append(2)
a.value.removeAtIndex(0)
a.value.append(3)
a.value[0] = 3
// Output:
//
// Array did change: [1]
// Array did change: [1, 2]
// Array did change: [2]
// Array did change: [2, 3]
// Array did change: [3, 3]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment