Skip to content

Commit

Permalink
Use @autoclosure so taht we dont retain Actions in memory
Browse files Browse the repository at this point in the history
Instead it will create them on the fly via the provided closure
  • Loading branch information
s4cha committed May 5, 2017
1 parent 7ce08fc commit 406de68
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions Source/Action.swift
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,11 @@ public func action<T:ActionProtocol>(_ userAction: T?) -> T.Output where T.Input
public class Actions {

public static let container = Container()

public static func plug<T:ActionProtocol>(_ action: T.Type, to implementation: T) {


public static func plug<T:ActionProtocol>(_ action: T.Type, to implementation: @autoclosure @escaping () -> T) {
container.register(action) { (r:Resolver) -> T in
return implementation
return implementation()
}
}

Expand All @@ -58,6 +59,6 @@ public class Actions {
}

infix operator <~
public func <~ <T:ActionProtocol>(left: T.Type, right:T) {
public func <~ <T:ActionProtocol>(left: T.Type, right: @autoclosure @escaping () -> T) {
Actions.plug(left, to: right)
}

0 comments on commit 406de68

Please sign in to comment.