ReactiveArray alternatives and similar libraries
Based on the "Utility" category.
Alternatively, view ReactiveArray alternatives based on common mentions on social networks and blogs.
-
SwifterSwift
:A handy collection of more than 360 native Swift 3 extensions to boost your productivity. -
SwiftGen-Storyboard
A tool to auto-generate Swift enums for all your Storyboards, Scenes and Segues constants + appropriate convenience accessors. -
SwiftGen
A collection of Swift tools to generate Swift code (enums for your assets, storyboards, Localizable.strings, …) -
LifetimeTracker
LifetimeTracker can surface retain cycle / memory issues right as you develop your application, and it will surface them to you immediately, so you can find them with more ease. -
SwiftLinkPreview
It makes a preview from an url, grabbing all information such as title, relevant texts and images. -
PinpointKit
An open-source iOS library in Swift that lets your testers and users send feedback with annotated screenshots and logs using a simple gesture. -
Highlighter
Highlight whatever you want! Highlighter will magically find UI objects such as UILabel, UITextView, UITexTfield, UIButton in your UITableViewCell or other Class. -
Pythonic.swift
Pythonic tool-belt for Swift: a Swift implementation of selected parts of Python standard library.
Get performance insights in less than 4 minutes
* Code Quality Rankings and insights are calculated and provided by Lumnify.
They vary from L1 to L5 with "L5" being the highest. Visit our partner's website for more details.
Do you think we are missing an alternative of ReactiveArray or a related project?
README
ReactiveArray
An array class implemented in Swift that can be observed using ReactiveCocoa's Signals.
Installation
Carthage
Add the following to your Cartfile:
github "Wolox/ReactiveArray"
Then run carthage update
.
Follow the current instructions in Carthage's README for up to date installation instructions.
You'll also need to add Result.framework
, Box.framework
and ReactiveCocoa.framework
to your Xcode
project.
Usage
Array operations
let array = ReactiveArray(elements: [1,2,3])
array.append(4) // => [1,2,3,4]
array.append(5) // => [1,2,3,4,5]
array[0] = 5 // => [5,2,3,4,5]
array.removeAtIndex(4) // => [5,2,3,4]
ReactiveArray
conforms to CollectionType
and MutableCollectionType
which allows you to perform operations like
map
or filter
.
Observing changes
The array can be observed for mutations using the signal
or producer
properties. Both Signal
and SignalProducer
will emit Operation
values on observation for any of the mutating
operations performed to the array.
Operation
is an enumeration with four cases. One for each
mutating operation: Append
, Insert
, Update
and RemoveElement
Using SignalProducer
Prints an append operation for each element that has already been stored in the array and then the corresponding operation for any new operation performed to the array.
let array = ReactiveArray(elements: [1,2,3])
array.producer |> start(next: { println($0) })
array[0] = 5
array[1] = 4
array.append(2)
array.removeAtIndex(2)
will print the following output:
.Append(value: 1)
.Append(value: 2)
.Append(value: 3)
.Update(value: 5, atIndex: 0)
.Update(value: 4, atIndex: 1)
.RemoveElement(atIndex:2)
Using Signal
The signal property will only emit values for operations performed in the array after observation.
let array = ReactiveArray(elements: [1,2,3])
array.signal.observe { println($0) }
array[0] = 5
array[1] = 4
array.append(2)
array.removeAtIndex(2)
will print the following output:
.Update(value: 5, atIndex: 0)
.Update(value: 4, atIndex: 1)
.RemoveElement(atIndex:2)
Using observableCount
You can also observe the observableCount
property that exposes a producer that emits the current amount of elements each time the array is mutated.
let array = ReactiveArray<String>()
array.observableCount.producer |> start(next: { println($0) })
array.append("Hello")
array.append("World")
will print the following output:
0
1
2
Mirror
Mirror creates a new ReactiveArray
by applying a transform
operation for each element contained in the original array. It is like map
but the returned array will mutate everytime the original array mutates.
let array = ReactiveArray(elements: [1,2,3])
let doubles = array.mirror { $0 * 2 }
doubles.producer |> start(next: { println($0) })
array.append(4)
array.append(5)
array[0] = 6
will print the following output:
.Append(value: 2)
.Append(value: 4)
.Append(value: 6)
.Append(value: 8)
.Append(value: 10)
.Update(value: 12, atIndex: 0)
Contributing
Setup project
If you want to contribute you need to setup your development environment first.
git clone https://github.com/Wolox/ReactiveArray.git
cd ReactiveArray
script/bootstrap
open ReactiveArray.xcodeproj
Environment dependencies
The following dependencies must be installed in your development machine.
- XCode & XCode command line tools
- Homebrew
- Ruby
- Bundler (sudoless)
- Carthage
- Gcovr
- SwiftCov
About
This project is maintained by Guido Marucci Blas and it was written by Wolox.
License
ReactiveArray is available under the MIT license.
Copyright (c) 2015 Guido Marucci Blas <[email protected]>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*Note that all licence references and agreements mentioned in the ReactiveArray README section above
are relevant to that project's source code only.