ReactiveSwift
ReactiveSwift copied to clipboard
Signal.merge reported issue after migrating from ReactiveSwift from 4.0.0 -> 6.6.0
due to migrating my existing application from Xcode-11 to Xcode-12. I am facing following issue issue in ReactiveSwift.
completed = Signal.merge(cancelled, finalized)
- Cannot assign value of type 'Signal<() -> Value, Never>' to type 'Signal<Value, Never>' ---> here assign variable declaration is let completed: Signal<Value, Never>
- Cannot convert value of type 'Signal<Value, Never>' to expected argument type 'Signal<() -> Value, Never>'
Provide suggestion how to resolve this issue to migrate ReactiveSwift from 4.0.0 -> 6.6.0
@sandeep3090 We ran into a similar issue with our project going from Xcode 11 -> 12. This has to do with changes that Apple has made to type inference. For example, if you did something like:
let isBaldBaby = Property.combineLatest(hasHair, age).map { hasHair, age in
return !hasHair && age < 3
}
Then if you command click on isBaldBaby
and show quick help, it'd give something like Property<() -> Bool>
, instead of Property<Bool>
as it would in Xcode 11. You can fix this by adding an explicit type definition to your variable. Sometimes I also had to add a return type to any maps, filters, etc. as well to help it along:
let isBaldBaby: Property<Bool> = Property.combineLatest(hasHair, age).map { hasHair, age -> Bool in
return !hasHair && age < 3
}
In your case, you'd want to add type annotations to cancelled
, finallized
, and completed
until it resolves to the correct type. I definitely recommend using the quick help inspector in Xcode (in the right-sidebar when you click on a symbol) for this since it'll tell you the exact type that it is getting resolved to.
@jagdeep-manik I am faced same issue now it's resolved. I hop in you case "age" signal have invalid mapping. So correct that or show me your code for hasHair or age. I will resolve that mapping.
Correct signal look like let age = agesignal.completed.compactMap { somestateCancelled }