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

Create decorator to set default value on first call #355

Open
shining-mind opened this issue May 10, 2023 · 1 comment
Open

Create decorator to set default value on first call #355

shining-mind opened this issue May 10, 2023 · 1 comment

Comments

@shining-mind
Copy link
Contributor

Let's assume we have a getter:

windowHeightStore: number = 0;

get windowHeight() {
  if (this.windowHeightStore === 0) {
    this.windowHeightStore = document.documentElement.clientHeight;
  }
  return this.windowHeightStore;
}

It would be nice to have a decorator:

@defaultValue(() => document.documentElement.clientHeight)
windowHeight: number;
@shining-mind
Copy link
Contributor Author

Also the @computed decorator should accept default value

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

1 participant