-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #9 from yankodimitrov/SignalKit-2.0
SignalKit 2.0
- Loading branch information
Showing
84 changed files
with
2,943 additions
and
372 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// | ||
// NSIndexSet+Signal.swift | ||
// SignalKit | ||
// | ||
// Created by Yanko Dimitrov on 9/30/15. | ||
// Copyright © 2015 Yanko Dimitrov. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
|
||
internal extension NSIndexSet { | ||
|
||
convenience init(withSet set: Set<Int>) { | ||
|
||
let indexSet = NSMutableIndexSet() | ||
|
||
for index in set { | ||
indexSet.addIndex(index) | ||
} | ||
|
||
self.init(indexSet: indexSet) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
// | ||
// UICollectionView+Signal.swift | ||
// SignalKit | ||
// | ||
// Created by Yanko Dimitrov on 10/1/15. | ||
// Copyright © 2015 Yanko Dimitrov. All rights reserved. | ||
// | ||
|
||
import UIKit | ||
|
||
public extension ArrayBindingObserver { | ||
|
||
/** | ||
Bind the changes in the ObservableArray to a UICollectionView | ||
|
||
*/ | ||
public func bindTo(collectionView collectionView: UICollectionView, dataSource: UICollectionViewDataSource) -> Disposable { | ||
|
||
bindingStrategy = CollectionViewBindingStrategy(collectionView: collectionView) | ||
|
||
collectionView.dataSource = dataSource | ||
collectionView.reloadData() | ||
|
||
return self | ||
} | ||
} | ||
|
||
internal final class CollectionViewBindingStrategy: ArrayBindingStrategyType { | ||
|
||
private weak var collectionView: UICollectionView? | ||
|
||
init(collectionView: UICollectionView) { | ||
|
||
self.collectionView = collectionView | ||
} | ||
|
||
func reloadAllSections() { | ||
|
||
collectionView?.reloadData() | ||
} | ||
|
||
func insertSections(sections: NSIndexSet) { | ||
|
||
collectionView?.insertSections(sections) | ||
} | ||
|
||
func reloadSections(sections: NSIndexSet) { | ||
|
||
collectionView?.reloadSections(sections) | ||
} | ||
|
||
func deleteSections(sections: NSIndexSet) { | ||
|
||
collectionView?.deleteSections(sections) | ||
} | ||
|
||
func reloadRowsInSections(sections: NSIndexSet) { | ||
|
||
collectionView?.reloadSections(sections) | ||
} | ||
|
||
func insertRowsAtIndexPaths(paths: [NSIndexPath]) { | ||
|
||
collectionView?.insertItemsAtIndexPaths(paths) | ||
} | ||
|
||
func reloadRowsAtIndexPaths(paths: [NSIndexPath]) { | ||
|
||
collectionView?.reloadItemsAtIndexPaths(paths) | ||
} | ||
|
||
func deleteRowsAtIndexPaths(paths: [NSIndexPath]) { | ||
|
||
collectionView?.deleteItemsAtIndexPaths(paths) | ||
} | ||
|
||
func performBatchUpdate(update: () -> Void) { | ||
|
||
collectionView?.performBatchUpdates(update, completion: nil) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
// | ||
// UITableView+Signal.swift | ||
// SignalKit | ||
// | ||
// Created by Yanko Dimitrov on 9/30/15. | ||
// Copyright © 2015 Yanko Dimitrov. All rights reserved. | ||
// | ||
|
||
import UIKit | ||
|
||
public extension ArrayBindingObserver { | ||
|
||
/** | ||
Bind the changes in the ObservableArray to a UITableView | ||
|
||
*/ | ||
public func bindTo(tableView tableView: UITableView, dataSource: UITableViewDataSource) -> Disposable { | ||
|
||
bindingStrategy = TableViewBindingStrategy(tableView: tableView) | ||
|
||
tableView.dataSource = dataSource | ||
tableView.reloadData() | ||
|
||
return self | ||
} | ||
} | ||
|
||
internal final class TableViewBindingStrategy: ArrayBindingStrategyType { | ||
|
||
private weak var tableView: UITableView? | ||
|
||
init(tableView: UITableView) { | ||
|
||
self.tableView = tableView | ||
} | ||
|
||
func reloadAllSections() { | ||
|
||
tableView?.reloadData() | ||
} | ||
|
||
func insertSections(sections: NSIndexSet) { | ||
|
||
tableView?.insertSections(sections, withRowAnimation: .Automatic) | ||
} | ||
|
||
func reloadSections(sections: NSIndexSet) { | ||
|
||
tableView?.reloadSections(sections, withRowAnimation: .Automatic) | ||
} | ||
|
||
func deleteSections(sections: NSIndexSet) { | ||
|
||
tableView?.deleteSections(sections, withRowAnimation: .Automatic) | ||
} | ||
|
||
func reloadRowsInSections(sections: NSIndexSet) { | ||
|
||
tableView?.reloadSections(sections, withRowAnimation: .Automatic) | ||
} | ||
|
||
func insertRowsAtIndexPaths(paths: [NSIndexPath]) { | ||
|
||
tableView?.insertRowsAtIndexPaths(paths, withRowAnimation: .Automatic) | ||
} | ||
|
||
func reloadRowsAtIndexPaths(paths: [NSIndexPath]) { | ||
|
||
tableView?.reloadRowsAtIndexPaths(paths, withRowAnimation: .Automatic) | ||
} | ||
|
||
func deleteRowsAtIndexPaths(paths: [NSIndexPath]) { | ||
|
||
tableView?.deleteRowsAtIndexPaths(paths, withRowAnimation: .Automatic) | ||
} | ||
|
||
func performBatchUpdate(update: () -> Void) { | ||
|
||
tableView?.beginUpdates() | ||
|
||
update() | ||
|
||
tableView?.endUpdates() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.