Skip to content

Commit 6be0287

Browse files
committed
Make Action retain its state property.
1 parent 0f2fc54 commit 6be0287

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

Sources/Action.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,9 @@ public final class Action<Input, Output, Error: Swift.Error> {
7878
public init<State: PropertyProtocol>(state property: State, enabledIf isEnabled: @escaping (State.Value) -> Bool, _ execute: @escaping (State.Value, Input) -> SignalProducer<Output, Error>) {
7979
deinitToken = Lifetime.Token()
8080
lifetime = Lifetime(deinitToken)
81+
82+
// Retain the `property` for the created `Action`.
83+
lifetime.ended.observeCompleted { _ = property }
8184

8285
executeClosure = { state, input in execute(state as! State.Value, input) }
8386

0 commit comments

Comments
 (0)