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

Vis Svelte | Fix component lifecycle logic #89

Merged
merged 3 commits into from
Jan 4, 2023
Merged

Conversation

reb-dev
Copy link
Collaborator

@reb-dev reb-dev commented Dec 29, 2022

Fixes #86

@rokotyan I spent some time investigating this and it seemed like the best thing to do was to change the way we handle component lifecycles in our svelte wrapper.

Before:

  • onMount: the setter method provided by the container is called (i.e. setAxis) which updates the container's config.
  • onDestroy: the same method is called with undefined to remove it from the container's config. This created a unique issue for axis because we need to know which config key (i.e. xAxis or yAxis) to make undefined. A workaround could have been to make an additional method called removeAxis but that seemed convoluted to me. I wanted to rethink our current approach and further separate the component logic from the container's.

Changes:

  • The component mounts/destroys independent of the container, but uses the action provided by the container as a side effect. So now after the axis mounts, the container will determine its type and create the onDestroy that will be called later.
  • The destroy() method is called on the wrapped components themselves now. I'm not sure how important it is but I realized we didn't do that before like we do in our react wrapper.

@rokotyan rokotyan added this to the Release v1.0.2 milestone Jan 4, 2023
@rokotyan rokotyan merged commit a98dce5 into main Jan 4, 2023
@rokotyan rokotyan deleted the fix/svelte-axis-bug branch January 10, 2023 02:14
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.

Svelte error when using axis
3 participants