AliSoftware / Dip

Simple Swift Dependency container. Use protocols to resolve your dependencies and avoid singletons / sharedInstances!
MIT License
978 stars 75 forks source link

Register with Scope and Factory #166

Closed bhushans closed 7 years ago

bhushans commented 7 years ago

Hello,

I have a generic functions that used to use for registering the factory. However, when I try to do it now, it starts throwing error Cannot invoke 'register' with an argument list of type '(ComponentScope, factory: () throws -> T)'

Here is the function. open func register(_ factory: () throws -> T) { recordMethods(T.self as! CDVPlugin.Type) container.register(DefaultScope, factory: factory) }

bhushans commented 7 years ago

I was able to resolve this issue by add @escaping before the closure.