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

Option to automatically namespace static data #2

Merged
merged 1 commit into from
Jul 6, 2018
Merged

Option to automatically namespace static data #2

merged 1 commit into from
Jul 6, 2018

Conversation

matheusgrieger
Copy link
Contributor

@matheusgrieger matheusgrieger commented Jul 6, 2018

Expands usage to allow for a single configuration option, namespaced: boolean, so that all static data will be namespaced into $static component property.

This is solely to avoid conflicts with other options and reactive data (same name, for instance), and helps you to remember which data is or isn't reactive.

Also, tried to add type definitions for TypeScript users, but my knowledge is not enough to extend Vue types.

Example usage with option and namespace:

import VueStatic from 'vue-static';

Vue.use(VueStatic, {
  namespaced: true
});
<template>
  <div>
    Reactive data: {{ normalData }}
    Static data: {{ $static.nonChangingValue }}
  </div>
</template>

<script>
export default {
  data() {
    return {
      normalData: 'this will be reactive'
    };
  },
  static() {
    return {
      nonChangingValue: 'this will not'
    };
  }
}
</script>

@samuelantonioli samuelantonioli merged commit 0f45c38 into samuelantonioli:master Jul 6, 2018
@samuelantonioli
Copy link
Owner

Thank you, good idea and clean code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants