npm.io
1.0.0 • Published 6 years ago

universal-miniapp-api-interceptor

Licence
BSD-3-Clause
Version
1.0.0
Deps
0
Size
4 kB
Vulns
0
Weekly
0

npm

Each platform Mini App interceptor function, through the provided factory function can quickly access the multi-platform Mini App API.

Installation

$ npm install universal-miniapp-api-interceptor --save

Usage

import { apiInterceptor, apiEventHandlerInterceptor } from 'universal-miniapp-api-interceptor';

const scanCode = apiInterceptor(my, {
  method: 'scan',
  optionsInterceptor: (options: IOptions) => {
    // process options
    return options;
  },
  successInterceptor: (res: any) => {
    // process success result
    return res;
  },
  failInterceptor: (err: any) => {
    // process fail error
    return err;
  }
});

const onAccelerometerChange = listenerInterceptor(my, {
  method: 'onAccelerometerChange'
});

Keywords