How to use the vue-class-component.createDecorator function in vue-class-component

To help you get started, we’ve selected a few vue-class-component examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github gamejolt / frontend-lib / components / route / route-store.ts View on Github external
export function WithRouteStore(options: RouteStoreOptions) {
	return createDecorator(componentOptions => {
		// Store the options passed in.
		componentOptions.routeStoreOptions = {
			...componentOptions.routeStoreOptions,
			...options,
		};

		// We unshift so that this always goes first before the RouteResolver
		// callback.
		componentOptions.mixins = componentOptions.mixins || [];
		componentOptions.mixins.unshift({
			beforeRouteEnter(route, _from, next) {
				const options = componentOptions.routeStoreOptions;
				if (options) {
					const { store, routeStoreClass, routeStoreName } = options;
					store.registerModule(routeStoreName, new routeStoreClass());
github logaretm / vee-validate / src / decorators.ts View on Github external
export function ValidationAction(action: 'validate' | 'reset' = 'validate') {
  return createDecorator((componentOptions, key) => {
    const actions = mapValidationActions([action]);
    if (!componentOptions.methods) {
      componentOptions.methods = {};
    }

    let originalMethod = componentOptions.methods[key];
    if (action === 'validate') {
      componentOptions.methods[key] = function() {
        actions[action].call(this).then((result: boolean) => {
          originalMethod.call(this, result);
        });
      };

      return;
    }
github huncwotjs / huncwot / store / index.js View on Github external
function makeDecorator(alias, namespace) {
    return createDecorator((componentOptions, key) => {
      let ns = namespace || componentOptions.namespace;

      if (!componentOptions[bindTo]) {
        componentOptions[bindTo] = {};
      }

      const mapObject = { [key]: alias };

      componentOptions[bindTo][key] =
        ns !== undefined ? mapFn(ns, mapObject)[key] : mapFn(mapObject)[key];
    });
  }
github huncwotjs / huncwot / store / index.js View on Github external
function makeDecorator(alias, namespace) {
    return createDecorator((componentOptions, key) => {
      let ns = namespace || componentOptions.namespace;

      if (!componentOptions.computed) {
        componentOptions.computed = {};
      }

      componentOptions.computed[key] =
        ns !== undefined ? sync(`${ns}/${key}`) : sync(`${key}`);
    });
  }
github kaorun343 / vue-property-decorator / src / vue-property-decorator.ts View on Github external
export function Watch(path: string, options: WatchOptions = {}) {
  const { deep = false, immediate = false } = options

  return createDecorator((componentOptions, handler) => {
    if (typeof componentOptions.watch !== 'object') {
      componentOptions.watch = Object.create(null)
    }

    const watch: any = componentOptions.watch

    if (typeof watch[path] === 'object' && !Array.isArray(watch[path])) {
      watch[path] = [watch[path]]
    } else if (typeof watch[path] === 'undefined') {
      watch[path] = []
    }

    watch[path].push({ handler, deep, immediate })
  })
}
github ktsn / vuex-class / src / bindings.ts View on Github external
function makeDecorator (map: any, namespace: string | undefined) {
    return createDecorator((componentOptions, key) => {
      if (!componentOptions[bindTo]) {
        componentOptions[bindTo] = {}
      }

      const mapObject = { [key]: map }

      componentOptions[bindTo]![key] = namespace !== undefined
        ? mapFn(namespace, mapObject)[key]
        : mapFn(mapObject)[key]
    })
  }
github nuxt-community / nuxt-property-decorator / src / nuxt-property-decorator.ts View on Github external
export function Once(event?: string): MethodDecorator {
  return createDecorator((componentOptions, k) => {
    const key = hyphenate(k)
    if (typeof componentOptions.created !== "function") {
      componentOptions.created = function() {}
    }
    const original = componentOptions.created
    componentOptions.created = function() {
      original()
      if (typeof componentOptions.methods !== "undefined") {
        this.$once(event || key, componentOptions.methods[k])
      }
    }
  })
}
github davestewart / vuex-pathify / src / helpers / decorators.js View on Github external
function Call (path) {
  if (typeof path !== 'string' || arguments.length > 1) { throw new Error('Property decorators can only be used for single property access') }
  return createDecorator((options, key) => {
    if (!options.methods) options.methods = {}
    options.methods[key] = call(path)
  })
}

vue-class-component

ES201X/TypeScript class decorator for Vue components

MIT
Latest version published 4 years ago

Package Health Score

64 / 100
Full package analysis