interface RunOptions { block?: boolean } export default (worker: string|string[], options: RunOptions = {}) => { const workers = typeof worker === 'string' ? [worker] : worker return (target: any, propertyKey: string, descriptor: PropertyDescriptor) => { const originalMethod = descriptor.value as (...args: any[]) => any descriptor.value = function (...args: any[]) { if (options.block && this.$busy(...workers)) { return } return this.$run(workers, () => originalMethod.bind(this)(...args)) } return descriptor } }