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

Reactive issue #184

Open
caesar1shi opened this issue Jan 31, 2024 · 7 comments
Open

Reactive issue #184

caesar1shi opened this issue Jan 31, 2024 · 7 comments

Comments

@caesar1shi
Copy link
Contributor

caesar1shi commented Jan 31, 2024

Is it necessary to set self.update() in the set function of ctx? Otherwise, we cannot get a response in the DOM when setting properties.
image
https://github.com/nuejs/nue/blob/master/packages/nuejs/src/browser/nue.js

@tipiirai
Copy link
Contributor

The self.update() updates the dom to reflect the properties on the component instance.

cannot get a response in the DOM when setting properties.

What exactly you mean by this?

Thanks!

@caesar1shi
Copy link
Contributor Author

caesar1shi commented Jan 31, 2024

<div class="sidebar { isCollapsed ? 'collapsed' : '' }">
  <script>
    onSidebarCollapse() {
      this.isCollapsed = true
    }

    onSidebarExpand() {
      this.isCollapsed = false
    }
  </script>
</div>

For example, after calling onSidebarExpand to assign a value to isCollapsed, it cannot change the value of the class. Because the call to self.update is currently missing.

@caesar1shi
Copy link
Contributor Author

We need to call self.update to update the component after setting properties, or we can just update the component content related to the property. As follows:

  function updateProperty(key) {
    expr.forEach((el) => {
      if (el.toString().includes(key))
        el();
    });
  }

  set(__, key, val) {
    if ($parent && $parent[key] !== void 0) {
      $parent[key] = val;
      $parent.update();
    } else {
      self[key] = val;
      self.updateProperty(key);
    }
    return true;
  }

@caesar1shi
Copy link
Contributor Author

The call to self.update is currently missing.
YWJ4IE8DROKQ16)7VM5A LO

@tipiirai
Copy link
Contributor

tipiirai commented Feb 2, 2024

Nicely spotted!

Note that the client-side Nue JS is not currently under heavy development because there are some major pieces in the product development roadmap before the SPA stuff. There are quite many issues on the reactive lib, but they're addressed later. I should add a note to the README file about this.

Also — to add self.update() to that spot might cause unwanted side-effects. I think we need a proper client-side test suite for the reactive pieces before adding that change.

@caesar1shi
Copy link
Contributor Author

Got it

@tipiirai
Copy link
Contributor

tipiirai commented Feb 5, 2024

Thanks. I created a pinned issue for this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants