Open evant opened 8 years ago
A single generic type param.
public class MyLoader extends Loader<Arg, Result> {
@Override
protected void onStart(Arg arg, Receiver receiver) { ... }
}
Arg arg = ...;
myLoader.start(arg);
pros:
cons:
myLoader.start(null):
).
null
to onStart()
but that behavior can be surprising if not expecting it.A vararg Object
param.
public class MyLoader extends Loader<Result> {
@Override
protected void onStart(Object[] args, Receiver receiver) { ... }
}
Arg arg = ...;
myLoader.start(arg);
pros:
myLoader.start(arg1, arg2)
).myLoader.start()
).cons:
A Bundle
param.
```java
public class MyLoader extends Loader<Result> {
@Override
protected void onStart(Bundle args, Receiver receiver) { ... }
}
Arg arg = ...;
Bundle args = new Bundle();
args.putParcelable("arg", arg);
myLoader.start(args);
pros:
cons:
I'm liking option 1, some of my networking calls using retrofit use @Post
, having a single @Body LoginUser
object holding the credentials, so this pattern is familiar.
For example, on signin, you'd want to pass a username and password to
Loader#restart()