Mon 21 Jul 22:43:21 CEST 2025
This commit is contained in:
parent
382a551461
commit
11551783ab
57
js/ui/cordova/plugins/cordova-plugin-networking-bluetooth/www/CDVNetEvent.js
vendored
Normal file
57
js/ui/cordova/plugins/cordova-plugin-networking-bluetooth/www/CDVNetEvent.js
vendored
Normal file
|
@ -0,0 +1,57 @@
|
|||
// Copyright 2016 Franco Bugnano
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
var CDVNetEvent = {
|
||||
init: function () {
|
||||
this.listeners = [];
|
||||
},
|
||||
|
||||
addListener: function (callback) {
|
||||
if (!this.hasListener(callback)) {
|
||||
this.listeners.push(callback);
|
||||
}
|
||||
},
|
||||
|
||||
removeListener: function (callback) {
|
||||
var
|
||||
i = this.listeners.indexOf(callback);
|
||||
;
|
||||
|
||||
if (i >= 0) {
|
||||
this.listeners.splice(i, 1);
|
||||
}
|
||||
},
|
||||
|
||||
hasListener: function (callback) {
|
||||
return (this.listeners.indexOf(callback) >= 0);
|
||||
},
|
||||
|
||||
hasListeners: function () {
|
||||
return Boolean(this.listeners.length);
|
||||
},
|
||||
|
||||
fire: function () {
|
||||
var
|
||||
i,
|
||||
len_listeners = this.listeners.length
|
||||
;
|
||||
|
||||
for (i = 0; i < len_listeners; i += 1) {
|
||||
this.listeners[i].apply(this, arguments);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = CDVNetEvent;
|
||||
|
Loading…
Reference in New Issue
Block a user