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

Rx Kotlin Nulls #49

Closed
sanchezz93 opened this issue Jun 23, 2022 · 0 comments
Closed

Rx Kotlin Nulls #49

sanchezz93 opened this issue Jun 23, 2022 · 0 comments

Comments

@sanchezz93
Copy link
Contributor

  • When generating code in Artist from the KotlinApiHelper we get the following
public open override fun clicks(): Observable<Unit> {
    if (clicks == null) {
    	....
         rxview_longCl().map()
    		.doOnNext(UiChecks.checkClickableRequirementsAction(this))
    		.doOnNext(ViewAnalytics.logTapFor(this, getContext())).subscribe(clicks)
    	}
    }
   ....
  }

The Kotlin compiler assumes that the clicks in the subscribe method is null even though we set it a few lines prior. A possible fix for this is adding a let call before the rx chain. This way we will prevent the compiler from prompting

smart cast to 'PublishRelay<Unit>' is impossible, because 'clicks' is a mutable property that could have been changed by this time

How we're planning on solving it

public open override fun clicks(): Observable<Unit> {
    if (clicks == null) {
    	....
        clicks?.let {
         rxview_longCl().map()
    		.doOnNext(UiChecks.checkClickableRequirementsAction(this))
    		.doOnNext(ViewAnalytics.logTapFor(this, getContext())).subscribe(it)
    	 }
       }
    }
    ....
  }
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

1 participant