-
Notifications
You must be signed in to change notification settings - Fork 82
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
Implement CircuitContext #325
Conversation
@@ -391,11 +390,6 @@ private fun KSFunctionDeclaration.assistedParameters( | |||
) | |||
} | |||
} | |||
type.isInstanceOf(symbols.circuitConfig) -> { |
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.
This shouldn't have been available as an assisted type anyway so no real loss here
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.
A couple problems I don't think this solution solves:
- There doesn't appear to be any way to get data from
CircuitContext
tags into a presenter or UI. At least not unless we want to manually build factories, which seems like a non-starter. This effectively means events occurring in Circuit can't be tied to events happening in the presenter or ui code. - It doesn't appear possible to tie events for nested Circuits (ie calling
CircuitConfig
from UI logic) to the parent Circuit.
We chatted offline about the following:
We can accomplish this via a delegating presenter implementation and factory that:
This was addressed by 79c7238 |
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.
Looks good to me 👍
This introduces a new
CircuitContext
API to factories to replace the currentCircuitConfig
parameter.The goal of
CircuitContext
is to offer a way to easily add extra context to presenter and UI factory requests and allow for extra flexibility to breadcrumb extra information via a tags API.CircuitContext
is mutable in nature and modeled similarly to Moshi'sJsonReader
API, and should not be kept past factory creation.Currently it exposes the global
CircuitConfig
and a tags API.The tags API should allow consumers to plumb through anything extra they need that doesn't necessarily fit in Circuit's core API, such as telemetry infrastructure. This is similar in nature to the tags APIs found in Moshi, OkHttp, KotlinPoet, etc.
Along the way I've implemented some new
EventListener
APIs with access to this. Its test is now beefed up and demonstrates a nice example of a very basic logging listener.