Hi,
In Android MVVM architecture, I am trying to @Inject ISuspendable through ViewModelModule, as I cannot pass this to my VMModel constructor.
@Module
abstract class ViewModelModule {
@Singleton
@Binds
abstract fun getSuspendable(aSuspendable: ACMSuspendableImpl): ISuspendable
@Binds
@IntoMap
@ViewModelKey(MonitorViewModel::class)
abstract fun bindsMonitorViewModell(monitorViewModel: MonitorViewModel): ViewModel
}
@Singleton
class ACMSuspendableImpl @Inject constructor() : ISuspendable {
override fun decrementSuspend() {
}
override fun suspendUpdates(): IUpdateSuspender {
TODO("not implemented")
}
override fun getIsSuspended(): Boolean {
TODO("not implemented")
}
override fun resumeUpdates(p0: IUpdateSuspender?) {
}
}
whereas my MonitorViewModel class as,
class MonitorViewModel @Inject constructor(context: Context) : BaseViewModel() {
@Inject
lateinit var acmSuspend: ISuspendable
private fun loadMonitorData() {
UpdateSuspender.using(acmSuspend) { //<! NULL ->
iapDataSeries.append(Timestamp.valueOf(mData100Hz.getRtcTimeStamp().toString()), mData100Hz.emr.iap)
uoColumnDataSeries.append(
Timestamp.valueOf(mData100Hz.getRtcTimeStamp().toString()),
mData100Hz.emr.totalVolume
)
}
}
How should I @Inject ISuspendable so that it should not be NULL. Please provide me some example snipped to work.
FYI,
I tried to follow the ECGViewModel but this sample used some custom solution and there is no use of DI.
BR,
Praween
- Praween Kumar asked 5 years ago
- last edited 5 years ago
-
FYI,License extended for evaluation period.
- You must login to post comments
Praween, please use the format code button when submitting questions with source-code.
Best regards,
Andrew
- Andrew Burnett-Thompson answered 5 years ago
- You must login to post comments
Hi Praween,
I’m not sure that this is correct place for this kind of question because it isn’t related to usage of SciChart components ( ISuspendable is just a simple Java interface so there should be no problem with DI ). It looks like that this issue is more related to usage of DI library so I would suggest to create a question on StackOverflow and tag it with DI library which you used.
Best regards,
Yura
- Yura Khariton answered 5 years ago
- You must login to post comments
Hi Yura,
Never mind. I was able to solve the problem. Thanks for your reply.
- Praween Kumar answered 5 years ago
- You must login to post comments
Please login first to submit.