Skip to content

Introduced ability to override AndroidMainThreadFeatureScheduler via plugin - #194

Open
LachlanMcKee wants to merge 1 commit into
badoo:masterfrom
LachlanMcKee:introduce-mvicore-android-plugin
Open

Introduced ability to override AndroidMainThreadFeatureScheduler via plugin#194
LachlanMcKee wants to merge 1 commit into
badoo:masterfrom
LachlanMcKee:introduce-mvicore-android-plugin

Conversation

@LachlanMcKee

@LachlanMcKee LachlanMcKee commented Aug 15, 2023

Copy link
Copy Markdown
Collaborator

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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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.

2 participants