Exemplo n.º 1
0
  action = function action(target, key, desc) {
    let actionFn;

    if (!isElementDescriptor([target, key, desc])) {
      actionFn = target;

      let decorator = function(target, key, desc, meta, isClassicDecorator) {
        assert(
          'The @action decorator may only be passed a method when used in classic classes. You should decorate methods directly in native classes',
          isClassicDecorator
        );

        assert(
          'The action() decorator must be passed a method when used in classic classes',
          typeof actionFn === 'function'
        );

        return setupAction(target, key, actionFn);
      };

      setClassicDecorator(decorator);

      return decorator;
    }

    actionFn = desc.value;

    assert(
      'The @action decorator must be applied to methods when used in native classes',
      typeof actionFn === 'function'
    );

    return setupAction(target, key, actionFn);
  };
Exemplo n.º 2
0
        assert(
          'The @action decorator may only be passed a method when used in classic classes. You should decorate methods directly in native classes',
          isClassicDecorator
        );

        assert(
          'The action() decorator must be passed a method when used in classic classes',
          typeof actionFn === 'function'
        );

        return setupAction(target, key, actionFn);
      };

      setClassicDecorator(decorator);

      return decorator;
    }

    actionFn = desc.value;

    assert(
      'The @action decorator must be applied to methods when used in native classes',
      typeof actionFn === 'function'
    );

    return setupAction(target, key, actionFn);
  };

  setClassicDecorator(action);
}