How to use the @bentley/ui-core.isPromiseLike function in @bentley/ui-core

To help you get started, we’ve selected a few @bentley/ui-core 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 imodeljs / imodeljs / ui / components / src / ui-components / tree / controlled / component / NodeContent.tsx View on Github external
const [label, setLabel] = useState(() => {
    const newLabel = getLabel();
    if (isPromiseLike(newLabel)) {
      newLabel.then((result) => setLabel(result)); // tslint:disable-line: no-floating-promises
      return ;
    }
    return newLabel;
  });
github imodeljs / imodeljs / ui / components / src / ui-components / tree / component / NodeContent.tsx View on Github external
private async updateLabel(props: TreeNodeContentProps) {
    const label = this.getLabel(props);
    if (isPromiseLike(label)) {
      const result = await label;

      if (this._isMounted)
        this.setState({ label: result }, this._onLabelStateChanged);
    } else {
      this.setState({ label }, this._onLabelStateChanged);
    }
  }
github imodeljs / imodeljs / ui / framework / src / ui-framework / imodel-components / visibility-tree / VisibilityTree.tsx View on Github external
return (node: TreeNodeItem): CheckBoxInfo | Promise => {
      const status = this.getNodeCheckBoxInfo(node);
      if (isPromiseLike(status))
        return status.then(combine);
      return combine(status);
    };
  }
github imodeljs / imodeljs / ui / components / src / ui-components / properties / LinkHandler.tsx View on Github external
export const renderLinks = (text: string | Promise, record: PropertyRecord): React.ReactNode | Promise => {
  if (isPromiseLike(text)) {
    return text.then((result) => renderText(result, record));
  }

  return renderText(text, record);
};
github imodeljs / imodeljs / ui / framework / src / ui-framework / pickers / ModelSelector / ModelSelectorTree.tsx View on Github external
return (node: TreeNodeItem): CheckBoxInfo | Promise => {
      const status = this.getNodeCheckBoxInfo(node);
      if (isPromiseLike(status)) return status.then(combine);
      return combine(status);
    };
  }
github imodeljs / imodeljs / ui / framework / src / ui-framework / imodel-components / visibility-tree / VisibilityTree.tsx View on Github external
private getNodeCheckBoxInfo(node: TreeNodeItem): CheckBoxInfo | Promise {
    if (!this._visibilityHandler)
      return { isVisible: false };

    const result = this._visibilityHandler.getDisplayStatus(node);
    if (isPromiseLike(result))
      return result.then(createCheckBoxInfo);
    return createCheckBoxInfo(result);
  }
github imodeljs / imodeljs / ui / components / src / ui-components / tree / component / BeInspireTree.ts View on Github external
nodes.forEach((n) => {
          if (!n.payload)
            return;

          const status = checkboxInfo(n.payload);
          if (isPromiseLike(status))
            promises.push(status.then((s) => this.updateNodeCheckboxInfo(n, s)));
          else
            this.updateNodeCheckboxInfo(n, status);
        });
        if (promises.length !== 0)