Repository: expo/expo
File: packages/expo-sensors/src/DeviceSensor.ts (TypeScript)

Code before:
    return this._nativeModule.addListener(this._nativeEventName, listener);
  }

  /**
   * Returns boolean which signifies if sensor has any listeners registered.
   */
  hasListeners(): boolean {
    return this._nativeModule.listenerCount(this._nativeEventName) > 0;
  }

  /**
   * Returns the registered listeners count.
   */
  getListenerCount(): number {
    return this._nativeModule.listenerCount(this._nativeEventName);
  }

  /**
   * Removes all registered listeners.
   */
  removeAllListeners(): void {
    this._nativeModule.removeAllListeners(this._nativeEventName);
  }

  /**
   * @deprecated use subscription.remove() instead
   */
  removeSubscription(subscription: EventSubscription): void {
    subscription.remove();
  }

  /**
   * Set the sensor update interval.
   *
   * @param intervalMs Desired interval in milliseconds between sensor updates.
   * > Starting from Android 12 (API level 31), the system has a 200Hz limit for each sensor updates.
   * >
   * > If you need an update interval of greater than 200Hz, you should
   * > * add `android.permission.HIGH_SAMPLING_RATE_SENSORS` to [**app.json** `permissions` field](/versions/latest/config/app/#permissions)
   * > * or if you are using an existing React Native project, add
   * > `<uses-permission android:name="android.permission.HIGH_SAMPLING_RATE_SENSORS"/>` to **AndroidManifest.xml**.
   */
  setUpdateInterval(intervalMs: number): void {
    if (!this._nativeModule.setUpdateInterval) {
      console.warn(`expo-sensors: setUpdateInterval() is not supported on ${Platform.OS}`);
    } else {
      this._nativeModule.setUpdateInterval(intervalMs);
    }
  }

  /**

Review comment (suggestion):
```suggestion
   * @deprecated use subscription.remove() instead.
```

Code after:
    return this._nativeModule.addListener(this._nativeEventName, listener);
  }

  /**
   * Returns boolean which signifies if sensor has any listeners registered.
   */
  hasListeners(): boolean {
    return this._nativeModule.listenerCount(this._nativeEventName) > 0;
  }

  /**
   * Returns the registered listeners count.
   */
  getListenerCount(): number {
    return this._nativeModule.listenerCount(this._nativeEventName);
  }

  /**
   * Removes all registered listeners.
   */
  removeAllListeners(): void {
    this._nativeModule.removeAllListeners(this._nativeEventName);
  }

  /**
   * @deprecated use subscription.remove() instead.
   */
  removeSubscription(subscription: EventSubscription): void {
    subscription.remove();
  }

  /**
   * Set the sensor update interval.
   *
   * @param intervalMs Desired interval in milliseconds between sensor updates.
   * > Starting from Android 12 (API level 31), the system has a 200Hz limit for each sensor updates.
   * >
   * > If you need an update interval of greater than 200Hz, you should
   * > * add `android.permission.HIGH_SAMPLING_RATE_SENSORS` to [**app.json** `permissions` field](/versions/latest/config/app/#permissions)
   * > * or if you are using an existing React Native project, add
   * > `<uses-permission android:name="android.permission.HIGH_SAMPLING_RATE_SENSORS"/>` to **AndroidManifest.xml**.
   */
  setUpdateInterval(intervalMs: number): void {
    if (!this._nativeModule.setUpdateInterval) {
      console.warn(`expo-sensors: setUpdateInterval() is not supported on ${Platform.OS}`);
    } else {
      this._nativeModule.setUpdateInterval(intervalMs);
    }
  }

  /**