Skip to content

Commit

Permalink
Small cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
lightsprint09 committed Jan 4, 2019
1 parent 709d1a2 commit 62d4083
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
10 changes: 5 additions & 5 deletions Source/DataProvider/DataProvider/CollectionDataProvider.swift
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public extension CollectionDataProvider {
/// Return the number of sections.
///
/// - Returns: the number of sections.
public func numberOfSections() -> Int {
func numberOfSections() -> Int {
return content.count
}
}
Expand All @@ -49,28 +49,28 @@ public extension CollectionDataProvider where Container.Index == Int,
///
/// - Parameter indexPath: the index path to get the object for.
/// - Returns: the object at the given index path.
public func object(at indexPath: IndexPath) -> Element {
func object(at indexPath: IndexPath) -> Element {
return content[indexPath.section][indexPath.item]
}

/// Returns the number of items in a given section.
///
/// - Parameter section: the section.
/// - Returns: number of items in the given section.
public func numberOfItems(inSection section: Int) -> Int {
func numberOfItems(inSection section: Int) -> Int {
return content[section].count
}
}

extension CollectionDataProvider where Element: Equatable {
public extension CollectionDataProvider where Element: Equatable {

/**
Returns the indexPath for a given object.

- parameter object: the object to find the indexPath for.
- return: the indexPath of the object, if available.
*/
public func indexPath(for object: Element) -> IndexPath? {
func indexPath(for object: Element) -> IndexPath? {
for section in 0..<numberOfSections() {
for item in 0..<numberOfItems(inSection: section) {
let indexPath = IndexPath(item: item, section: section)
Expand Down
12 changes: 6 additions & 6 deletions Source/DataProvider/DataProvider/JoinedDataProvider.swift
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@ public final class JoinedDataProvider<Element>: DataProvider {
}
}

deinit {
dataProviders.enumerated().forEach { index, dataProvider in
dataProvider.observable.removeObserver(observer: observers[index])
}
}

/// An observable where one can subscribe to changes of data provider.
public var observable: DataProviderObservable { return innerObaseravle }

Expand Down Expand Up @@ -116,12 +122,6 @@ public final class JoinedDataProvider<Element>: DataProvider {
}
}

deinit {
dataProviders.enumerated().forEach { ( index, dataProvider) in
dataProvider.observable.removeObserver(observer: observers[index])
}
}

private let dataProviders: [AnyDataProvider<Element>]
private let innerObaseravle = DefaultDataProviderObservable()
private var observers: [NSObjectProtocol]!
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,11 @@ public final class LazyTransformationDataProvider<TargetType>: DataProvider {
}

extension DataProvider {

/// Lazy transforms the content witha given closure into a new data provider
/// Lazy transforms the content with a given closure into a new data provider.
///
/// - Parameter transform: the closure which transforms the element into the target value
/// - Returns: a `LazyTransformationDataProvider` which provides the newly transformed objects.
/// - Returns: a `LazyTransformationDataProvider` which provides newly transformed objects.
///
/// - SeeAlso: `LazyTransformationDataProvider`
public func lazyTransform<TargetType>(_ transform: @escaping (Element) -> TargetType) ->
Expand Down

0 comments on commit 62d4083

Please sign in to comment.