index.js
655 Bytes
export const toPromise = (platform) => {
return (method) => {
return (option) => {
return new Promise ((resolve, reject) => {
platform[method]({
...option,
success: (res) => { resolve(res) },
fail: (err) => { reject(err) }
})
})
}
}
}
export const toPromiseWX = toPromise(wx);
const setStoragePromise = toPromiseWX('setStorage');
export const getSettingPromise = toPromiseWX('getSetting');
export const setStorageValueForKey = (key, value) => {
return setStoragePromise({
key,
data: value
});
}
import EventEmitter from './event.js';
export const Event = EventEmitter;