UNPKG

vue-plugin-helper-decorator

Version:
77 lines (70 loc) 2.47 kB
(function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('vue-class-component')) : typeof define === 'function' && define.amd ? define(['exports', 'vue-class-component'], factory) : (factory((global['vue-plugin-helper-decorator'] = {}),global.VueClassComponent)); }(this, (function (exports,vueClassComponent) { 'use strict'; /** * Vue-Socket.io helper * Adding the method in the component sockets options * https://github.com/MetinSeylan/Vue-Socket.io */ function SocketIO(socketOption) { return vueClassComponent.createDecorator(function (componentOptions, handler) { const options = componentOptions; if (typeof options.sockets !== 'object') { options.sockets = Object.create(null); } if (socketOption && socketOption.name) { if (Array.isArray(socketOption.name)) { socketOption.name.forEach(name => { options.sockets[name] = options.methods[handler]; }); } else { options.sockets[socketOption.name] = options.methods[handler]; } } else { options.sockets[handler] = options.methods[handler]; } }); } /** * Vulidate helper * Reflect the method to component validations option * https://github.com/monterail/vuelidate */ function Validation() { return vueClassComponent.createDecorator(function (componentOptions, handler) { const options = componentOptions; options.validations = options.methods[handler]; }); } /** * Idle-vue helper * Reflect the method to component onIdle option * https://github.com/soixantecircuits/idle-vue */ function OnIdle() { return vueClassComponent.createDecorator(function (componentOptions, handler) { const options = componentOptions; options.onIdle = options.methods[handler]; }); } /** * Idle-vue helper * Reflect the method to component onActive option * https://github.com/soixantecircuits/idle-vue */ function OnActive() { return vueClassComponent.createDecorator(function (componentOptions, handler) { const options = componentOptions; options.onActive = options.methods[handler]; }); } exports.SocketIO = SocketIO; exports.Validation = Validation; exports.OnIdle = OnIdle; exports.OnActive = OnActive; Object.defineProperty(exports, '__esModule', { value: true }); })));