Last active
February 5, 2018 18:48
-
-
Save rnystrom/d36a1c221574005f9b38a661a47c63eb to your computer and use it in GitHub Desktop.
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
// ListSwiftAdapterDataSource.swift | |
public class Value { | |
public let value: ListSwiftDiffable | |
public let constructor: () -> ListSectionController | |
public init<T>(value: T, constructor: @escaping () -> ListSwiftSectionController<T>) { | |
self.value = value | |
self.constructor = constructor | |
} | |
} | |
public protocol ListSwiftAdapterDataSource: class { | |
func values(adapter: ListSwiftAdapter) -> [ Value ] | |
} | |
// ViewController.swift | |
var values: [ListSwiftDiffable] = // .... | |
func values(adapter: ListSwiftAdapter) -> [Value] { | |
return values.flatMap({ (value: Any) -> Value? in | |
if let value = value as? Person { | |
return Value(value: value, constructor: { PersonSectionController() }) | |
} | |
return nil | |
}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment