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

Raise non-fatal error if node called outside main thread #386

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

Conversation

LachlanMcKee
Copy link
Collaborator

Description:
Trigger RIBs.ErrorHandler#handleNonFatalError whenever a RIB node is interacted with off the main thread.

@LachlanMcKee LachlanMcKee changed the title Raise fatal error if node called outside main thread Raise non-fatal error if node called outside main thread Mar 15, 2023
@@ -48,6 +49,7 @@ open class Node<V : RibView> @VisibleForTesting internal constructor(
val buildParams: BuildParams<*>,
private val viewFactory: ViewFactory<V>?,
private val retainedInstanceStore: RetainedInstanceStore,
private val isOnMainThreadFunc: () -> Boolean,
Copy link
Collaborator

Choose a reason for hiding this comment

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

We need to make it overridable for every junit tested Node in our codebase, which does not seem achievable.

In general makes sense (we do not support any multi-threading anyway, comparing to Appyx which is guarded by coroutines context and/or atomic mutable states).

Let's take a default implementation from RIBs singleton and add RIBs.isOnMainThread and try to override it somehow in tests, potentially in NodeTestHelper and InteractorTestHelper? But the problem there that we do not reset them. (Maybe it is ok just to give up and override always without reset).

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