The mPaaS framework provides developers with more JSAPI and OpenAPI capabilities, and also provide users with a variety of convenient services through Mini Program.
Notes
APIs starting with my.on are used to listen to system events and receive a callback function as a parameter. When a system event is triggered, the callback function is called, and the callback function can be passed to the corresponding APIs starting with my.off to remove the listner. If you call the APIs starting with my.off directly, all the listners are removed. For example:
Page({onLoad() {this.callback = this.callback.bind(this);my.onBLECharacteristicValueChange(this.callback);},onUnload() {// Remove listener when the page is unloadedmy.offBLECharacteristicValueChange(this.callback);},callback(res) {console.log(res);},});
All other APIs receive an object as the parameter. You can specify success (call success), fail (call failure), or complete (call success or failure) to receive the interface call result. The result of callback is typically an object unless otherwise specified, and error/errorMessage indicates that the call is failed. The return value after the call is a promise object. For example:
my.httpRequest({url: '/x.htm',success:(res1) => {},}).then((res2) => {// res1 === res2},(res2) => {console.log(res.error, res.errorMessage);})