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

Add getter methods to store() object #191

Closed
cferdinandi opened this issue Oct 17, 2023 · 0 comments
Closed

Add getter methods to store() object #191

cferdinandi opened this issue Oct 17, 2023 · 0 comments
Labels
discussion enhancement New feature or request wontfix This will not be worked on

Comments

@cferdinandi
Copy link
Owner

Is it worth having getter methods on the store() object that can be used to get and modify data without triggering a signal event?

let count = store(0, {
  increase (num) {
    num++;
  },
  decrease (num) {
      num--;
  }
}, {
  getDouble (num) {
     return num * 2;
  }
});

While you can technically use actions this way already, each one emits a signal event and triggers a reactive UI update on components that use the object data.

With getter methods, the data would remain immutable and simply provide a useful way to bind data manipulations to the store() itself.

Of course, this same thing can be handled today with helper methods as well...

let count = store(0, {
  increase (num) {
    num++;
  },
  decrease (num) {
      num--;
  }
});

function getDouble (num) {
  return num * 2;
}

getDouble(count.value);

As a result, I'm not sure getter methods add all that much value, but they DO increase the complexity of the project.

@cferdinandi cferdinandi added enhancement New feature or request discussion labels Oct 17, 2023
@cferdinandi cferdinandi added the wontfix This will not be worked on label Oct 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
discussion enhancement New feature or request wontfix This will not be worked on
Projects
None yet
Development

No branches or pull requests

1 participant