当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript inferno-shared.throwError函数代码示例

本文整理汇总了TypeScript中inferno-shared.throwError函数的典型用法代码示例。如果您正苦于以下问题:TypeScript throwError函数的具体用法?TypeScript throwError怎么用?TypeScript throwError使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了throwError函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: hydrate

function hydrate(
  vNode: VNode,
  dom: Element,
  lifecycle: LifecycleClass,
  context: Object,
  isSVG: boolean
) {
  const flags = vNode.flags;

  if (flags & VNodeFlags.Component) {
    hydrateComponent(
      vNode,
      dom,
      lifecycle,
      context,
      isSVG,
      (flags & VNodeFlags.ComponentClass) > 0
    );
  } else if (flags & VNodeFlags.Element) {
    hydrateElement(vNode, dom, lifecycle, context, isSVG);
  } else if (flags & VNodeFlags.Text) {
    hydrateText(vNode, dom);
  } else if (flags & VNodeFlags.Void) {
    hydrateVoid(vNode, dom);
  } else {
    if (process.env.NODE_ENV !== "production") {
      throwError(
        `hydrate() expects a valid VNode, instead it received an object with the type "${typeof vNode}".`
      );
    }
    throwError();
  }
}
开发者ID:russelgal,项目名称:inferno,代码行数:33,代码来源:hydration.ts

示例2: patchEvent

export function patchEvent(name: string, lastValue, nextValue, dom) {
  if (lastValue !== nextValue) {
    if (delegatedEvents.has(name)) {
      handleEvent(name, lastValue, nextValue, dom);
    } else {
      const nameLowerCase = name.toLowerCase();
      const domEvent = dom[nameLowerCase];
      // if the function is wrapped, that means it's been controlled by a wrapper
      if (domEvent && domEvent.wrapped) {
        return;
      }
      if (!isFunction(nextValue) && !isNullOrUndef(nextValue)) {
        const linkEvent = nextValue.event;

        if (linkEvent && isFunction(linkEvent)) {
          dom[nameLowerCase] = function(e) {
            linkEvent(nextValue.data, e);
          };
        } else {
          if (process.env.NODE_ENV !== "production") {
            throwError(
              `an event on a VNode "${name}". was not a function or a valid linkEvent.`
            );
          }
          throwError();
        }
      } else {
        dom[nameLowerCase] = nextValue;
      }
    }
  }
}
开发者ID:russelgal,项目名称:inferno,代码行数:32,代码来源:patching.ts

示例3: createFunctionalComponentInput

export function createFunctionalComponentInput(
  vNode: VNode,
  component,
  props: Props,
  context: Object
) {
  let input = component(props, context);

  if (isArray(input)) {
    if (process.env.NODE_ENV !== "production") {
      throwError(
        "a valid Inferno VNode (or null) must be returned from a component render. You may have returned an array or an invalid object."
      );
    }
    throwError();
  } else if (isInvalid(input)) {
    input = createVoidVNode();
  } else if (isStringOrNumber(input)) {
    input = createTextVNode(input, null);
  } else {
    if (input.dom) {
      input = directClone(input);
    }
    if (input.flags & VNodeFlags.Component) {
      // if we have an input that is also a component, we run into a tricky situation
      // where the root vNode needs to always have the correct DOM entry
      // so we break monomorphism on our input and supply it our vNode as parentVNode
      // we can optimise this in the future, but this gets us out of a lot of issues
      input.parentVNode = vNode;
    }
  }
  return input;
}
开发者ID:russelgal,项目名称:inferno,代码行数:33,代码来源:utils.ts

示例4: findDOMNode

export function findDOMNode(ref) {
  if (!options.findDOMNodeEnabled) {
    if (process.env.NODE_ENV !== "production") {
      throwError(
        "findDOMNode() has been disabled, use Inferno.options.findDOMNodeEnabled = true; enabled findDOMNode(). Warning this can significantly impact performance!"
      );
    }
    throwError();
  }
  const dom = ref && ref.nodeType ? ref : null;

  return componentToDOMNodeMap.get(ref) || dom;
}
开发者ID:russelgal,项目名称:inferno,代码行数:13,代码来源:rendering.ts

示例5: mountRef

export function mountRef(dom: Element, value, lifecycle: LifecycleClass) {
  if (isFunction(value)) {
    lifecycle.addListener(() => value(dom));
  } else {
    if (isInvalid(value)) {
      return;
    }
    if (process.env.NODE_ENV !== "production") {
      throwError(
        'string "refs" are not supported in Inferno 1.0. Use callback "refs" instead.'
      );
    }
    throwError();
  }
}
开发者ID:russelgal,项目名称:inferno,代码行数:15,代码来源:mounting.ts

示例6: findAllInVNodeTree

export function findAllInVNodeTree(
  vNodeTree: VNode,
  predicate: (vNode: VNode) => boolean
): any {
  if (isVNode(vNodeTree)) {
    let result: VNode[] = predicate(vNodeTree) ? [vNodeTree] : [];
    const children: any = vNodeTree.children;

    if (isRenderedClassComponent(children)) {
      result = result.concat(findAllInVNodeTree(
        children._lastInput,
        predicate
      ) as VNode[]);
    } else if (isVNode(children)) {
      result = result.concat(findAllInVNodeTree(
        children,
        predicate
      ) as VNode[]);
    } else if (isArray(children)) {
      children.forEach(child => {
        result = result.concat(findAllInVNodeTree(child, predicate) as VNode[]);
      });
    }
    return result;
  } else {
    throwError(
      "findAllInVNodeTree(vNodeTree, predicate) vNodeTree must be a VNode instance"
    );
  }
}
开发者ID:russelgal,项目名称:inferno,代码行数:30,代码来源:index.ts

示例7: connect

/**
 * Wraps a component and provides stores as props
 */
function connect(arg1: any, arg2?: any): any {
  if (typeof arg1 === "string") {
    throwError("Store names should be provided as array");
  }

  if (Array.isArray(arg1)) {
    // component needs stores
    if (!arg2) {
      // invoked as decorator
      return _componentClass => connect(arg1, _componentClass);
    } else {
      // TODO: deprecate this invocation style
      return inject.apply(null, arg1)(connect(arg2));
    }
  }
  const componentClass = arg1;

  // Stateless function component:
  // If it is function but doesn't seem to be a Inferno class constructor,
  // wrap it to a Inferno class automatically
  if (
    typeof componentClass === "function" &&
    (!componentClass.prototype || !componentClass.prototype.render) &&
    !componentClass.isReactClass &&
    !Component.isPrototypeOf(componentClass)
  ) {
    const newClass = createClass({
      contextTypes: componentClass.contextTypes,
      displayName: componentClass.displayName || componentClass.name,
      getDefaultProps: () => componentClass.defaultProps,
      propTypes: componentClass.propTypes,
      render() {
        return componentClass.call(this, this.props, this.context);
      }
    });

    return connect(newClass);
  }

  if (!componentClass) {
    throwError('Please pass a valid component to "connect"');
  }

  componentClass.isMobXReactObserver = true;
  return makeReactive(componentClass);
}
开发者ID:russelgal,项目名称:inferno,代码行数:49,代码来源:connect.ts

示例8: mountClassComponentCallbacks

export function mountClassComponentCallbacks(
  vNode: VNode,
  ref,
  instance,
  lifecycle: LifecycleClass
) {
  if (ref) {
    if (isFunction(ref)) {
      ref(instance);
    } else {
      if (process.env.NODE_ENV !== "production") {
        if (isStringOrNumber(ref)) {
          throwError(
            'string "refs" are not supported in Inferno 1.0. Use callback "refs" instead.'
          );
        } else if (isObject(ref) && vNode.flags & VNodeFlags.ComponentClass) {
          throwError(
            "functional component lifecycle events are not supported on ES2015 class components."
          );
        } else {
          throwError(
            `a bad value for "ref" was used on component: "${JSON.stringify(
              ref
            )}"`
          );
        }
      }
      throwError();
    }
  }
  const hasDidMount = !isUndefined(instance.componentDidMount);
  const afterMount = options.afterMount;

  if (hasDidMount || !isNull(afterMount)) {
    lifecycle.addListener(() => {
      instance._updating = true;
      if (afterMount) {
        afterMount(vNode);
      }
      if (hasDidMount) {
        instance.componentDidMount();
      }
      instance._updating = false;
    });
  }
}
开发者ID:russelgal,项目名称:inferno,代码行数:46,代码来源:mounting.ts

示例9: trackComponents

export function trackComponents() {
  if (typeof WeakMap === "undefined") {
    throwError(
      "[inferno-mobx] tracking components is not supported in this browser."
    );
  }
  if (!isDevtoolsEnabled) {
    isDevtoolsEnabled = true;
  }
}
开发者ID:russelgal,项目名称:inferno,代码行数:10,代码来源:makeReactive.ts

示例10: mount

export function mount(
  vNode: VNode,
  parentDom: Element | null,
  lifecycle: LifecycleClass,
  context: Object,
  isSVG: boolean
) {
  const flags = vNode.flags;

  if (flags & VNodeFlags.Element) {
    return mountElement(vNode, parentDom, lifecycle, context, isSVG);
  } else if (flags & VNodeFlags.Component) {
    return mountComponent(
      vNode,
      parentDom,
      lifecycle,
      context,
      isSVG,
      (flags & VNodeFlags.ComponentClass) > 0
    );
  } else if (flags & VNodeFlags.Void) {
    return mountVoid(vNode, parentDom);
  } else if (flags & VNodeFlags.Text) {
    return mountText(vNode, parentDom);
  } else {
    if (process.env.NODE_ENV !== "production") {
      if (typeof vNode === "object") {
        throwError(
          `mount() received an object that's not a valid VNode, you should stringify it first. Object: "${JSON.stringify(
            vNode
          )}".`
        );
      } else {
        throwError(
          `mount() expects a valid VNode, instead it received an object with the type "${typeof vNode}".`
        );
      }
    }
    throwError();
  }
}
开发者ID:russelgal,项目名称:inferno,代码行数:41,代码来源:mounting.ts


注:本文中的inferno-shared.throwError函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。