-
Notifications
You must be signed in to change notification settings - Fork 8
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
Allow Fragment::arg
with nullable parameters.
#420
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR. I've added tests, added an overload for argOrNull
to handle args which are missing entirely, and removed the Java overload.
The CI wasn't executing because by default, GitHub does not run actions against PRs from forks until they've been allowed by a repo admin. Aaand I didn't notice that I needed to approve it. 🤷 Sorry about that.
* @param clazz type class expected for this argument | ||
* @see FragmentInjectFactory for instantiating fragments with arguments | ||
*/ | ||
public fun <A : Any?> Fragment.arg(bundleKey: String, clazz: Class<A>): Lazy<A> = lazy { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not willing to introduce an overload for Java compatibility, considering that this library is tied to a Kotlin compiler plugin.
f16fcf1
to
ff03ca7
Compare
Remove the non-null restriction on `Fragment::arg` using an `isInstance` check instead of the `as?` cast. This requires more type information at runtime, so a `Class<A>` param is added as well as a convenience inline function with reified type parameter.
Update based on [this response](actions/checkout#551 (comment)). This may not work for private repos.
- remove overloaded java version - use KClass<*> type names for error messages (e.g., `kotlin.Int` vs `java.lang.Integer`) - fill out kdoc - add tests
ff03ca7
to
681bfe3
Compare
Remove the non-null restriction on
Fragment::arg
using anisInstance
check instead of the
as?
cast. This requires more type information atruntime, so a
Class<A>
param is added as well as a convenience inlinefunction with reified type parameter.
I didn't see any tests for this function at the moment, so none were added. Just let me know if you would like this to change.
Binary incompatibility: Adds a new parameter to the only overload of
arg
visible from Java.closes #414