Skip to content

Create decorator to set default value on first call #355

Open
@shining-mind

Description

@shining-mind

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;

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions