Locatable alternatives and similar libraries
Based on the "Dependency Injection" category.
Alternatively, view Locatable alternatives based on common mentions on social networks and blogs.
-
Swinject
Dependency injection framework for Swift with iOS/macOS/Linux -
Resolver
Swift Ultralight Dependency Injection / Service Locator framework -
AnnotationInject
Compile-time type safe Swift dependency injection annotations
Appwrite - The open-source backend cloud platform
* Code Quality Rankings and insights are calculated and provided by Lumnify.
They vary from L1 to L5 with "L5" being the highest.
Do you think we are missing an alternative of Locatable or a related project?
Popular Comparisons
README
Locatable
Context
Locatable is a Swift micro framework that leverages Property Wrappers to implement the Service Locator pattern, through a custom attribute @Locatable
.
Here's an example of how it can be used:
protocol Servicing {
func action()
}
class Service: Servicing {
func action() {
print("I'm performing a service 😊")
}
}
Locator.register(Servicing.self, { return Service() })
class MyController {
@Locatable(.sharedInstance) var service: Servicing
func work() {
self.service.action()
}
}
let controller = MyController()
controller.work() // I'm performing a service 😊
For convenience, some shorthand syntax are also available:
// leverages @autoclosure
Locator.register(Servicing.self, Service())
// leverages default argument values
Locator.register { return Service() as Servicing }
Service locating supports two distinct semantics:
// Will return an instance that is shared across the app
Locatable(.sharedInstance) var service: Servicing
// Will return a new instance every time
Locatable(.newInstance) var service: Servicing
Requirements
Xcode 11+ & Swift 5.1
Installation
CocoaPods
Add the following to your Podfile
:
pod "Locatable"
Carthage
Add the following to your Cartfile
:
github "vincent-pradeilles/locatable"
Author
- Twitter: @v_pradeilles