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

Selective Imports #914

Merged
merged 5 commits into from
Nov 1, 2017
Merged

Selective Imports #914

merged 5 commits into from
Nov 1, 2017

Conversation

logaretm
Copy link
Owner

@logaretm logaretm commented Oct 25, 2017

Overview

Currently vee-validate is only usable by using Vue's plugin API

Vue.use(VeeValidate);

Which is simple enough for most workflows, however some scenarios require having a rather selective installation, for example you want vee-validate to be working in some components but not others. Which could improve load time when using async components.

Another factor is the global pollution, VeeValidate currently injects a mixin and a directive in all components regardless if they are going to be using it or not, which is unnecessary.

This PR aims to add the ability to install vee-validate manually by converting the directive and mixin to standalone parts, so they can be imported and injected selectively into a component.

import { directive, mixin } from 'vee-validate';

export default {
  directives: { validate: directive },
  mixins: [mixin],
  $_veeValidate: {
     // VeeValidate config here
  }
};

Issues Fixed

closes #778

Any thoughts are welcome, this PR might either get merged or rejected as this is not a must-have feature.

@codecov
Copy link

codecov bot commented Oct 25, 2017

Codecov Report

Merging #914 into master will increase coverage by 0.17%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #914      +/-   ##
==========================================
+ Coverage    98.8%   98.97%   +0.17%     
==========================================
  Files          45       46       +1     
  Lines        1256     1270      +14     
  Branches      407      412       +5     
==========================================
+ Hits         1241     1257      +16     
+ Misses         13       12       -1     
+ Partials        2        1       -1
Impacted Files Coverage Δ
src/core/generator.js 100% <100%> (ø) ⬆️
src/directive.js 100% <100%> (ø) ⬆️
src/mixin.js 94.11% <100%> (+4.11%) ⬆️
src/config.js 100% <100%> (ø)
src/rules/required.js 100% <0%> (ø) ⬆️
src/rules/decimal.js 100% <0%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 13fd125...0d658b3. Read the comment docs.

@logaretm logaretm merged commit 2227f47 into master Nov 1, 2017
@logaretm logaretm changed the title [WIP] Selective Imports Selective Imports Nov 6, 2017
@logaretm logaretm deleted the feature/selective-install branch November 21, 2017 17:41
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.

Provide a Mixin as an alternative to the Plugin
1 participant