Skip to content

Commit 406de68

Browse files
committed
Use @autoclosure so taht we dont retain Actions in memory
Instead it will create them on the fly via the provided closure
1 parent 7ce08fc commit 406de68

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

Source/Action.swift

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,11 @@ public func action<T:ActionProtocol>(_ userAction: T?) -> T.Output where T.Input
4545
public class Actions {
4646

4747
public static let container = Container()
48-
49-
public static func plug<T:ActionProtocol>(_ action: T.Type, to implementation: T) {
48+
49+
50+
public static func plug<T:ActionProtocol>(_ action: T.Type, to implementation: @autoclosure @escaping () -> T) {
5051
container.register(action) { (r:Resolver) -> T in
51-
return implementation
52+
return implementation()
5253
}
5354
}
5455

@@ -58,6 +59,6 @@ public class Actions {
5859
}
5960

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

0 commit comments

Comments
 (0)