Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/libsteve/aggregate
An aggregating object which can compose protocol implementations from various objects
https://github.com/libsteve/aggregate
ios macos objective-c swift
Last synced: 15 days ago
JSON representation
An aggregating object which can compose protocol implementations from various objects
- Host: GitHub
- URL: https://github.com/libsteve/aggregate
- Owner: libsteve
- License: other
- Created: 2018-03-06T02:22:20.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2018-03-06T19:02:53.000Z (almost 7 years ago)
- Last Synced: 2024-10-29T17:59:00.612Z (2 months ago)
- Topics: ios, macos, objective-c, swift
- Language: Swift
- Homepage:
- Size: 10.7 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
Aggregate
=========`Aggregate` is an object which can compose protocol implementations from various objects
This can be useful for dividing large protocol implementations into separate objects,
and then combining them here to pass to a client as a single delegate, data source, or object.```swift
import Aggregate@objc protocol Foo {
func doThis()
}@objc protocol Bar {
func doThat()
}@objc EagerBeaver: NSObject, Foo {
func doThis() {
print("I did this!")
}
}@objc Underachiever: NSObject, Foo, Bar {
func doThis() {
print("Do I have to do this?")
}func doThat() {
print("Do I have to do that?")
}
}let averageJoe = Aggregate(of: [EagerBeaver(), Underachiever()]) as! Foo & Bar
averageJoe.doThis() // prints "I did this!"
averageJoe.doThat() // prints "Do I have to do that?"
```It is important to note that the order of objects in the `targets` array denotes the calling
order for composed objects with duplicate method implementations, where the first target
has the highest prioritization. This is why `Underachiever`'s `doThis` implementation wasn't
called in the previous example.