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

Manage Defaults #38

Open
vermacodes opened this issue Oct 26, 2023 · 2 comments
Open

Manage Defaults #38

vermacodes opened this issue Oct 26, 2023 · 2 comments
Labels
enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed

Comments

@vermacodes
Copy link
Owner

I've created a TypeScript type called TfvarAddonsType, and I want to use default values for this type at multiple places throughout my code. Here's how I'm going to do it:

  1. Defining Default Values:

    First, I'll define default values for the TfvarAddonsType. I'll create a constant object with these default values:

    const defaultTfvarAddons: TfvarAddonsType = {
      appGateway: false,
      microsoftDefender: false,
      virtualNode: false,
      httpApplicationRouting: false,
    };
  2. Using Default Values:

    I can now use the defaultTfvarAddons object as a starting point wherever I need to create an instance of TfvarAddonsType with default values. For example:

    const someComponentConfig: TfvarAddonsType = { ...defaultTfvarAddons };
    
    // If needed, I can also modify specific properties
    someComponentConfig.appGateway = true;
  3. Reusing Default Values:

    To maintain consistency and make it easy to update defaults in the future, I'll reuse the defaultTfvarAddons object throughout my code whenever I need to initialize an object of type TfvarAddonsType with default values.

Here's the complete example:

const defaultTfvarAddons: TfvarAddonsType = {
  appGateway: false,
  microsoftDefender: false,
  virtualNode: false,
  httpApplicationRouting: false,
};

// Example usage
const someComponentConfig: TfvarAddonsType = { ...defaultTfvarAddons };
// I can modify specific properties as needed
someComponentConfig.appGateway = true;

// Reusing default values in other parts of my code
const anotherComponentConfig: TfvarAddonsType = { ...defaultTfvarAddons };

This approach allows me to maintain and apply default values consistently throughout my code.

@vermacodes vermacodes added enhancement New feature or request help wanted Extra attention is needed good first issue Good for newcomers labels Oct 26, 2023
@vermacodes
Copy link
Owner Author

Its already implemented on client side, see how to make it work on server side.

@vermacodes
Copy link
Owner Author

The defaults are mentioned in both client and server side. That should not be the case. it must only be on the server. The client should be as dumb as possible (IMO of course) but keeping same thing at two places doesn't seem right.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

1 participant