Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CB-4541 refactor: tree #2326

Merged
merged 2 commits into from
Jan 24, 2024
Merged

CB-4541 refactor: tree #2326

merged 2 commits into from
Jan 24, 2024

Conversation

Wroud
Copy link
Member

@Wroud Wroud commented Jan 24, 2024

No description provided.

@Wroud Wroud self-assigned this Jan 24, 2024
@Wroud Wroud merged commit b0a34c7 into devel Jan 24, 2024
1 of 3 checks passed

return (
<div ref={mountOptimization.setRootRef} style={{ overflow: 'auto', position: 'relative' }}>
<NodeSizeCacheContext.Provider value={elementsSizeCache}>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this amount of contexts scares me. at this point we should think how it would affect amount of rerenders in the tree

Comment on lines +66 to +71
const [nodeCache] = useState(
() =>
new MetadataMap<string, IComputedValue<INode>>(id =>
computed(() => applyTransforms(id, options.getNode(id), [rootNodeTransformer(options.rootId), ...(options.nodeTransformers || [])])),
),
);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is hard to undestand. please decompose it a little bit

Comment on lines +72 to +83
const [childrenCache] = useState(
() =>
new MetadataMap<string, IComputedValue<string[]>>(id =>
computed(() => applyTransforms(id, options.getChildren(id), options.childrenTransformers)),
),
);
const [stateCache] = useState(
() =>
new MetadataMap<string, IComputedValue<INodeState>>(id =>
computed(() => applyTransforms(id, state.getState(id), [rootNodeStateTransformer(options.rootId), ...(options.stateTransformers || [])])),
),
);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here

},
}),
{ state: observable.ref, rootId: observable.ref },
{ state, rootId: options.rootId },
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is not a pure function. please add here some deps so all functions uses this operator instead of get what it need outside of this scope

return useObservableRef(
() => ({
getState(id: string): Readonly<INodeState> {
return state.get(id);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this.state


this.element = element;
if (element) {
this.observer = new ResizeObserver(this.handleResize);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this one needs to be tested manually. cause as far as I remember resizeobserver can track only one axis. wether is width or height (dont remember which one). if it is important to track both I would recommend to use addEventListener('resize', this.handleResize)

@serge-rider serge-rider deleted the refactor/cb-4541/tree branch February 21, 2024 11:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants