Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Signal.merge reported issue after migrating from ReactiveSwift from 4.0.0 -> 6.6.0 #838

Open
sandeep3090 opened this issue Aug 31, 2021 · 2 comments

Comments

@sandeep3090
Copy link

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)

  1. Cannot assign value of type 'Signal<() -> Value, Never>' to type 'Signal<Value, Never>' ---> here assign variable declaration is let completed: Signal<Value, Never>
  2. 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

@jagdeep-manik
Copy link

jagdeep-manik commented Oct 6, 2021

@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.

@sandeep3090
Copy link
Author

@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 }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants