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

Re-review DOM sync approach. #1540

Open
lifeart opened this issue Dec 26, 2023 · 1 comment
Open

Re-review DOM sync approach. #1540

lifeart opened this issue Dec 26, 2023 · 1 comment

Comments

@lifeart
Copy link
Contributor

lifeart commented Dec 26, 2023

It seems we could explore different way to sync DOM with our state.
Instead of tags revalidation, we could explicitly mark "invalid" tags and resolve related opcodes to it.

Pseudocode:

TAG_ID = 12;

OpcodesForTag = {
  [TAG_ID] = [UpdateAttr, UpdateTextContent]
}

TagsToRevalidate = [];

Tag {
   id = TAG_ID;
   update() {
       this.value = 42;
       TagsToRevalidate.push(this);
   }
}

While (TRUE) {
   TagsToRevalidate.ForEach(Tag => {
      const value = tag.value;
      OpcodesForTag[this.id].forEach( opcode => {
          opcode(value);
      });
   });
}

Here is sample implementation concept: https://codepen.io/lifeart/pen/abMzEZm?editors=0110

Includes:

  • helpers
  • tags combination
  • basic DOM update ops
  • if condition
image

Tldr:

current glimmer-vm tag invalidation approach:
dirtryTag -> scheduleRerender -> validate all existing tags in application -> iterate over all opcodes and if changed -> execute
approach in issue:
dirtyTag -> scheduleRerender -> getOpcodesForTag(tag) -> execute

@lifeart lifeart changed the title Re-review REVISION approach. Re-review DOM sync approach. Dec 26, 2023
@NullVoxPopuli
Copy link
Contributor

Now that we have perf testing in ci, a pr that does this would be very interesting!

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

No branches or pull requests

2 participants