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

Introduced ability to override AndroidMainThreadFeatureScheduler via plugin #194

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

LachlanMcKee
Copy link
Collaborator

@LachlanMcKee LachlanMcKee commented Aug 15, 2023

Description

Introduced mechanism to override the AndroidMainThreadFeatureScheduler via plugin.
This makes it easier to test logic (similar to overriding RxJava schedulers)

Check list

  • I have updated CHANGELOG.md if required.
  • I have updated documentation if required.

@LachlanMcKee LachlanMcKee force-pushed the introduce-mvicore-android-plugin branch from d2370fc to f474107 Compare August 15, 2023 15:09
/**
* Overrides the [AndroidMainThreadFeatureScheduler].
*/
fun setMainThreadFeatureScheduler(schedulerProvider: () -> FeatureScheduler) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the point of using provider if you invoke it instantly?
Wanted to make it lazy?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

RxJava uses these as functions. I assume this is because some users may want to do some lazy initialisation.
It thought it would be wise to leave a similar option for users.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because in RxJava these providers are actually lazy and invoked only when we invoke Schedulers.io() (or other getter).
In our case we just create a lamda and instantly invoke it.

* The default implementation of the [AndroidMainThreadFeatureScheduler] which delegates to the
* RxAndroid main thread scheduler
*/
object Default : FeatureScheduler {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hide? We have reset() for reset. Otherwise not clear what to use: AndroidMainThreadFeatureScheduler or AndroidMainThreadFeatureScheduler.Default.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seems reasonable

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

Successfully merging this pull request may close these issues.

None yet

2 participants