Skip to content
This repository has been archived by the owner on Oct 10, 2018. It is now read-only.

darrarski/DRRxObservableArray

Repository files navigation

DRRxObservableArray

Build Status Build Status CocoaPods

Generic observable array for RxSwift. When its content changes (elements are inserted, removed or updated) it emits events from events Observable.

Usage

Example usage:

import RxSwift
import DRRxObservableArray

var observableArray = ObservableArray(["a", "b", "c"])
let _ = observableArray.events.subscribe(onNext: { event in 
	switch event {
		case .inserted(let indices, let elements):
			print("Inserted elements: \(elements) at indices: \(indices)")
		case .deleted(let indices, let elements):
			print("Removed elements: \(elements) at indices: \(indices)")
		case .updated(let indices, let oldElements, let newElements):
			print("Replaced elements: \(oldElements) at indices: \(indices) with elements: \(newElements)")
	}
})

observableArray.append("d")
// Inserted elements: ["d"] at indices: [3]

observableArray.removeLast()
// Removed elements: ["d"] at indices: [3]

observableArray[1] = "B"
// Replaced elements: ["b"] at indices: [1] with elements: ["B"] 

Check out included unit tests for more examples.

Instalation

You can integrate DRRxObservableArray with your project using CocoaPods. To do so, you will need to add following line to your Podfile:

pod 'DRRxObservableArray', '~> 1.0'

You can also download zip archive of given release from releases page.

License

The MIT License (MIT) - check out included LICENSE file