Usage

Device SupportGroup Not Support

Getting Started

SmartTapToRunAbility is available from @ray-js/panel-sdk@1.11.0.

Basic use

Here is an example of how to use SmartTapToRunAbility in JavaScript:

import { SmartTapToRunAbility } from '@ray-js/panel-sdk';

// Create an instance of SmartTapToRunAbility
const TapToRun = new SmartTapToRunAbility().init();

// Call the functions of TapToRunModel
TapToRun.getTapToRunRules()
  .then(result => {
    // Handle the returned result
  })
  .catch(error => {
    // Handle error cases
  });

Ray & SDM

Here is an example of how to use SmartTapToRunAbility with Ray & SDM:

src/devices/index.ts

Generate the wireless switch smart device model with the built-in tap-to-run ability

import { SmartDeviceModel, SmartTapToRunAbility } from '@ray-js/panel-sdk';

const options = {
  abilities: [new SmartTapToRunAbility()],
};

const devices = {
  wireless: new SmartDeviceModel<SmartDeviceSchema, { tapToRun: SmartTapToRunAbility }>(options)
};

src/app.tsx

Integrate with the React ecosystem using SdmProvider

import React from 'react';
import 'ray';
import '@/i18n';
import { kit, SdmProvider } from '@ray-js/panel-sdk';
import { devices } from '@/devices';

const { initPanelEnvironment } = kit;

interface Props {
  children: React.ReactNode;
}

initPanelEnvironment({ useDefaultOffline: true });

export default class App extends React.Component<Props> {
  onLaunch() {
    console.info('=== App onLaunch');
  }

  render() {
    return (
      <SdmProvider value={devices.sensor}>{this.props.children}</SdmProvider>
    );
  }
}

Notes

The SmartTapToRunAbility is based on the following atomic APIs, so the @ray-js/ray version needs to be greater than ^1.5.15: