@workplus/codash
v0.11.0
Published
A Cordova utility library.
Downloads
12
Readme
Codash
- 可配置,易用,轻松实现cordova promisify;
- 可添加拦截器,处理流程更方便;
- 接口可模拟,无需写两套同名方法;
- 提供常用方法,如绑定物理返回按钮,文件上传下载等。
使用 WorkPlus 扫一扫,查看在线 demo.
Docs
Install
npm install @workplus/codash --save
Usage
import { Cordova, deviceReady } from '@workplus/codash';
// 实例化,相关可用配置属性,请查看文档
const wp = new Cordova();
// 设置拦截器
wp.interceptors.before.use((config) => {
return config;
}, err => console.log(err));
wp.interceptors.after.use((response) => {
return response;
}, err => console.log(err));
// 创建promisify的cordova方法
const authHook = wp.addHook('WorkPlus_Auth');
const getUserTicket = authHook.create('getUserTicket');
const getAccessToken = wp.create('WorkPlus_Auth', 'getAccessToken');
// deviceReady 同样可以配置,具体请查看文档
deviceReady({ isMock: false })
.then(() => Promise.all([getUserTicket(), getAccessToken()]))
.then((res) => {})
.catch((err) => {});
Author
Hejx