You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Accessing the stateSnapshot parameter inside a MutateState block should be forbidden by a lint Rule.
funonActionXDoFoo(action:ActionX, stateSnapshot:State) {
....returnMutateState {
stateSnapshot.copy( ... ) // Accessing must be forbidden because lambda parameter state must be used instead
}
}
The text was updated successfully, but these errors were encountered:
This might be a bit easier now that the snapshot is a property on State since you can search for usages of that specifically instead of an arbitrary parameter. I think one other issue that this check should cover is that the object returned in the lambda is created inside the lambda, which will also reduce the risk of creating it based on an outdated snapshot.
fun onActionXDoFoo(action: ActionX, stateSnapshot: State) {
....
val newState = stateSnapshot.copy( ... )
return MutateState {
newState // Returning newState must be forbidden because it was created outside the lambda where we can't check whether the snapshot was used to create it
}
}
In summary:
state.snapshot should never be accessed inside the lambda
the returned object has to be created inside the lambda
Accessing the stateSnapshot parameter inside a MutateState block should be forbidden by a lint Rule.
The text was updated successfully, but these errors were encountered: