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

Trigger a full PHANTOM re—render when Redux state changes but no individual nodes were swapped #2

Open
sidiousvic opened this issue Jun 30, 2020 · 0 comments
Assignees
Labels
💅🏼 enhancement New feature or request

Comments

@sidiousvic
Copy link
Owner

sidiousvic commented Jun 30, 2020

In order for a re—render to be triggered, an element must be bound to its data via the data-phantom attribute.

      <h1 data-phantom="${slices}" id="slices-h1">${slices}</h1>

In the example above, the element is wrapping around the slices variable. Thus, if slices were to change, we desire a re—render. Phantom will know to do so via data-phantom.

The issue:

      <h1 id="slices-h1">${slices}</h1>

User has forgotten to bind a stateful element. Phantom does not know this element is bound to slices. It will not re—render upon a Redux state change. This may be confusing to the user.

Solutions

1. Throw an error when a user neglects data-phantom
Not all nodes need to be bound via data-phantom.

2. Throw an error when an element depends on a state variable and user neglects to bind it with data-phantom
If there was a way to know of this dependency, the data-phantom would already be unnecessary. This will also become an issue.

3. Trigger a full PHANTOM re—render when Redux state changes but no individual nodes were swapped

phantom tries to be efficient by using the PseudoDOM to compare and change swapped nodes. If no nodes were swapped but state updated, user may have forgotten to bind a stateful element.

This should probably be done within the renderPseudoElement() function, which is ran on reduxStore.subscribe().

Set a flag for whether swapElement() has run. If not, run a full re—render.

@sidiousvic sidiousvic added the 💅🏼 enhancement New feature or request label Jun 30, 2020
@sidiousvic sidiousvic self-assigned this Jun 30, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
💅🏼 enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant