Resolved: Capacitor v3 Motion api – using AccelListenerEvent properties

Question:

I am using Capacitor version 3 and I’m trying out the Motion Api.
In the documentation here, the AccelListenerEvent comes with some properties which I want to set but there are no examples of how to use this.
So the part I’m using is addListener(‘orientation’, …)
I basically want to set the interval.
I’ve added this:
import { Component } from '@angular/core';
import { PluginListenerHandle } from '@capacitor/core';
import { Motion, AccelListenerEvent } from '@capacitor/motion';


@Component({
  selector: 'app-home',
  templateUrl: 'home.page.html',
  styleUrls: ['home.page.scss'],
})
export class HomePage {

  accelHandler: PluginListenerHandle;
  accelListenerEvent: AccelListenerEvent;

  constructor() {
    this.accelListenerEvent.interval = 10;
  }
But it doesn’t like it in the constructor.
Does anyone have any ideas on how to set these properties?

Answer:

You can access the properties this way:
Motion.addListener('accel', event => {
  console.log('Interval:', event.interval);
});
Since this is an event, you can only receive values, not set them.

If you have better answer, please add a comment about this, thank you!