SciChart® the market leader in Fast WPF Charts, WPF 3D Charts, and iOS Chart & Android Chart Components

0
0

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

Version
v2.2.2.2424
  • Praween Kumar
    FYI,License extended for evaluation period.
  • You must to post comments
0
0

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

  • You must to post comments
0
0

Hi Yura,

Never mind. I was able to solve the problem. Thanks for your reply.

  • You must to post comments
0
0

Praween, please use the format code button when submitting questions with source-code.

Best regards,
Andrew

Images
  • You must to post comments
Showing 3 results
Your Answer

Please first to submit.