Skip to content

Commit

Permalink
feat: return data promise to onNodeClick (#3549)
Browse files Browse the repository at this point in the history
* feat: return data promise to `onNodeClick`

* chore: correct argument order
  • Loading branch information
haakonflatval-cognite authored Aug 7, 2023
1 parent 2d7fb4a commit a03296a
Showing 1 changed file with 4 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export type Reveal3DResourcesProps = {
resources: AddResourceOptions[];
fdmAssetMappingConfig?: FdmAssetMappingsConfig;
styling?: Reveal3DResourcesStyling;
onNodeClick?: (node: NodeDataResult | undefined) => void;
onNodeClick?: (node: Promise<NodeDataResult | undefined>) => void;
};

export const Reveal3DResources = ({
Expand Down Expand Up @@ -75,12 +75,9 @@ export const Reveal3DResources = ({

useEffect(() => {
const callback = (event: PointerEventData): void => {
void (async (event: PointerEventData): Promise<void> => {
if (onNodeClick === undefined) return;
const data = await queryMappedData(viewer, client, fdmSdk, event, fdmAssetMappingConfig);

onNodeClick(data);
})(event);
if (onNodeClick === undefined) return;
const data = queryMappedData(viewer, client, fdmSdk, event, fdmAssetMappingConfig);
onNodeClick(data);
};

viewer.on('click', callback);
Expand Down

0 comments on commit a03296a

Please sign in to comment.