MCPcopy
hub / github.com/HumanSignal/label-studio / eventsMixin

Function eventsMixin

docs/themes/htx/source/js/vue.js:2356–2465  ·  view source on GitHub ↗
(Vue)

Source from the content-addressed store, hash-verified

2354 }
2355
2356 function eventsMixin(Vue) {
2357 var hookRE = /^hook:/;
2358 Vue.prototype.$on = function(event, fn) {
2359 var this$1 = this;
2360
2361 var vm = this;
2362 if (Array.isArray(event)) {
2363 for (var i = 0, l = event.length; i < l; i++) {
2364 this$1.$on(event[i], fn);
2365 }
2366 } else {
2367 (vm._events[event] || (vm._events[event] = [])).push(fn);
2368 // optimize hook:event cost by using a boolean flag marked at registration
2369 // instead of a hash lookup
2370 if (hookRE.test(event)) {
2371 vm._hasHookEvent = true;
2372 }
2373 }
2374 return vm;
2375 };
2376
2377 Vue.prototype.$once = function(event, fn) {
2378 var vm = this;
2379 function on() {
2380 vm.$off(event, on);
2381 fn.apply(vm, arguments);
2382 }
2383 on.fn = fn;
2384 vm.$on(event, on);
2385 return vm;
2386 };
2387
2388 Vue.prototype.$off = function(event, fn) {
2389 var this$1 = this;
2390
2391 var vm = this;
2392 // all
2393 if (!arguments.length) {
2394 vm._events = Object.create(null);
2395 return vm;
2396 }
2397 // array of events
2398 if (Array.isArray(event)) {
2399 for (var i = 0, l = event.length; i < l; i++) {
2400 this$1.$off(event[i], fn);
2401 }
2402 return vm;
2403 }
2404 // specific event
2405 var cbs = vm._events[event];
2406 if (!cbs) {
2407 return vm;
2408 }
2409 if (!fn) {
2410 vm._events[event] = null;
2411 return vm;
2412 }
2413 if (fn) {

Callers 1

vue.jsFile · 0.85

Calls 3

toArrayFunction · 0.85
handleErrorFunction · 0.85
createMethod · 0.45

Tested by

no test coverage detected