my.offSocketError

Use this API to unregister listener to WebSocket error events.

Sample Code

copy
Page({
  onLoad() {
    this.callback = this.callback.bind(this);
    my.onSocketError(this.callback);
  },
  onUnload() {
    my.offSocketError(this.callback);
  },
  callback(res) {
  },
})

Note:The case is only for reference. Please use your own URL to test.

Whether to pass callback value or not

  • If the callback value is not passed, the callbacks of all events will be removed. The sample code is as follows:
copy
my.offSocketError();
  • If the callback value is passed, only the corresponding callback is removed. The sample code is as follows:
copy
my.offSocketError(this.callback);