jw
06/30/2022, 5:59 PMAidan Low
06/30/2022, 6:03 PM{ "foo": "1" }
I'd like to end up with the string { "foo": "1", "timestamp": "39483984" }
Aidan Low
06/30/2022, 6:05 PMMohamed Ibrahim
06/30/2022, 7:11 PMKotlinPeot
, I mean is it a try and error after compiling the project?
excuse my ignorance this is the first time I’m using it.jw
06/30/2022, 7:13 PMAidan Low
06/30/2022, 7:15 PMColton Idle
07/02/2022, 3:45 PMjw
07/02/2022, 3:49 PMjw
07/02/2022, 3:54 PMColton Idle
07/02/2022, 4:24 PMColton Idle
07/02/2022, 5:32 PMval moshi = Moshi.Builder()
.addLast(KotlinJsonAdapterFactory())
.build()
val testResponse: TestResponse? = moshi.adapter(TestResponse::class.java).fromJsonValue(result.data)
return testResponse!!
Kinda based off of that. Should I store moshi globally? and then do moshi.adapter() at every callsite? Or is the adapter something that should be add() 'd to the moshi instance?
edit: actually. maybe that actually doesn't make sense since the callsite needs to know the exact type at the callsite.jessewilson
07/02/2022, 5:56 PMColton Idle
07/02/2022, 6:26 PMNote that the reflection adapter transitively depends on thelibrary which is a 2.5 MiB .jar file.kotlin-reflect
jessewilson
07/02/2022, 7:26 PMjessewilson
07/02/2022, 7:26 PMBenoit Quenaudon
07/02/2022, 7:50 PMZac Sweers
07/02/2022, 8:23 PMPaul Woitaschek
07/02/2022, 8:27 PMPaul Woitaschek
07/02/2022, 8:29 PMPaul Woitaschek
07/02/2022, 8:30 PMMatthias Geisler
07/03/2022, 6:43 PMeygraber
07/03/2022, 11:36 PMLukasz Kalnik
07/06/2022, 4:03 PMCallAdapter
for Retrofit which converts the responses to Either<Failure, Success>
type (from the Arrow.kt library).
Now I would like to attach something in the call chain, if the call result is an IOException
then I want to notify the UI that possibly the network connection is gone.
Is there some mechanism to do it?
Currently I tried to attach another CallAdapter
just for this purpose (which basically just should pass the Call unchanged, but as a side-effect emit an event to the UI in the onFailure()
callback of the Call<T>
).
However it doesn't seem to work when put as the first CallAdapter
in chain. There is an error that Moshi converter tries to already parse the call after the first adapter (not waiting for the second one, which outputs the Either<F, S>
type). It complains that it cannot parse JSON to a Call<T>
object.Marc Plano-Lesay
07/07/2022, 12:12 AMPresenter
, and a few implementations of those. E.g.:
@ContributesMultibinding(PresenterScope::class, boundType = Presenter::class)
@StringKey("foo")
class FooPresenter @Inject constructor() : Presenter {}
My main file looks like this:
class Main @Inject constructor(
private val presenters: Map<String, Presenter>,
) {}
@Singleton
@MergeComponent(PresenterScope::class)
interface Provider {
fun main(): Main
}
fun main(args: Array<String>) {
DaggerProvider.builder().build().main().main(args)
}
The presenters injection fails, Dagger complains that there's no provide method. However, if I declare my provider like this:
@Singleton
@MergeComponent(PresenterScope::class)
interface Provider {
fun main(): Main
val presenters: Map<String, Presenter
}
There, Dagger is finding it (if I remove it from my Main
class that is). I feel like I'm missing something obvious to provide that dependency to my Main
class, but I can't figure out what?Gaurav Tyagi
07/08/2022, 11:20 AMGaurav Tyagi
07/08/2022, 11:20 AMMichal Klimczak
07/11/2022, 6:08 PMJavier
07/13/2022, 1:25 PMJavier
07/13/2022, 1:28 PMpaparazzi.gif
is not supported yet in ComposeColton Idle
07/15/2022, 12:56 AMval cardsJsonResponse: String = ...
// We can just use a reified extension!
val adapter = moshi.adapter<List<Card>>()
val cards: List<Card> = adapter.fromJson(cardsJsonResponse)
Cool. Seems simple enough:
val adapter = moshi.adapter<List<Book>>()
Compilation error: None of the following functions can be called with the arguments supplied.
Colton Idle
07/15/2022, 12:56 AMval cardsJsonResponse: String = ...
// We can just use a reified extension!
val adapter = moshi.adapter<List<Card>>()
val cards: List<Card> = adapter.fromJson(cardsJsonResponse)
Cool. Seems simple enough:
val adapter = moshi.adapter<List<Book>>()
Compilation error: None of the following functions can be called with the arguments supplied.