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

Document Vue component controllers as function instead objects #181

Open
rafaelcamargo opened this issue Feb 26, 2021 · 0 comments
Open
Labels
enhancement New feature or request

Comments

@rafaelcamargo
Copy link
Member

By now, we declare an object to represent some Vue component controller. In some cases, it leads to unpleasant experiences. In addition, documenting Vue component controllers as function will make clearer how exactly to import the components used on the example.

How it is currently done:

{
  title: 'Default Button',
  controller: {
    methods: {
      onClick(){
        window.alert("Clicked!");
      }
    }
  },
  template: `
  <pd-button :on-click="onClick">
    Click Here
  </pd-button>`
}

How it should be done:

{
  title: 'Default Button',
  controller: function(){
    const { pdButton } = myComponentsLib; // Make clearer where the component comes from

    return {
      components: {
        pdButton
      },
      methods: {
        onClick(){
          window.alert("Clicked!");
        }
      };
    }
  },
  template: `
  <pd-button :on-click="onClick">
    Click Here
  </pd-button>`
}
@rafaelcamargo rafaelcamargo added the enhancement New feature or request label Mar 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant