-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #74 from dhershman1/development
v4.0.0
- Loading branch information
Showing
9 changed files
with
1,814 additions
and
964 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,7 +17,8 @@ It attaches itself to an event for actions | |
- [Modifiers](#modifiers) | ||
- [Options](#options) | ||
- [Option Defaults](#option-defaults) | ||
- [getDirective Usage](#getdirective-usage) | ||
- [Vue3 Setup](#vue3-setup) | ||
- [Vue2 Setup](#vue2-setup) | ||
- [Usage](#usage) | ||
- [Modifier Usage](#modifier-usage) | ||
- [Overwriting Events](#overwriting-events) | ||
|
@@ -81,39 +82,36 @@ import debounce from 'https://unpkg.com/[email protected]/dist/debounce.min.mjs | |
import vueDebounce from 'https://unpkg.com/[email protected]/dist/vue-debounce.min.mjs'; | ||
``` | ||
|
||
## getDirective Usage | ||
## Vue3 Setup | ||
|
||
As of v3.0.0 a new function called `getDirective` is now exported, this allows you to import a function that lets you create the debounce directive at any level in your app instead of just globally. | ||
Usage has two flows based on which version of Vue you're currently using, if you use vue2 then those instructions are right below | ||
|
||
### Arguments | ||
|
||
This function takes in 2 arguments, they are: | ||
|
||
- `version` : `String` - This is the version of vue you're using, simply put `'2'` or `'3'` here | ||
- Version automatically defaults to version 2 | ||
- This is so that backwards compatibility can still be supported, since I don't have access to the Vue context when you don't install globally | ||
- `opts` : `Object` - This is the options object, use it the same way you would use it if using vue-debounce globally | ||
With vue3 we simply need to import the new directive function `vue3Debounce` this function takes in an object of options (found above) | ||
|
||
Using `vue-debounce` Globally: | ||
```js | ||
import { getDirective } from 'vue-debounce' | ||
import { vue3Debounce } from 'vue-debounce' | ||
import { createApp } from 'vue'; | ||
import App from './App.vue'; | ||
|
||
const app = createApp(App) | ||
app | ||
.directive('debounce', vue3Debounce({ lock: true })) | ||
.mount('#app'); | ||
``` | ||
|
||
const component = { | ||
directives: { | ||
// Please see above for arguments you can pass to this function | ||
debounce: getDirective() | ||
} | ||
} | ||
Using `vue-debounce` at a component level: | ||
```js | ||
import { vue3Debounce } from 'vue-debounce' | ||
|
||
// If you are using vue 3 you MUST tell the function this by passing in the first argument | ||
const component = { | ||
export default { | ||
directives: { | ||
// Pass in 3 to tell the function you're using vue 3, I'm going to work on improving this in the future | ||
debounce: getDirective(3) | ||
debounce: vue3Debounce({ lock: true }) | ||
} | ||
} | ||
``` | ||
|
||
## Usage | ||
## Vue2 Setup | ||
|
||
First make sure we tell vue to use it | ||
|
||
|
@@ -144,6 +142,8 @@ Vue.use(vueDebounce, { | |
}) | ||
``` | ||
|
||
## Usage | ||
|
||
Then attach a time:format to the directive, and set the value to the function you want to call and attach it to your input element | ||
|
||
Example: | ||
|
Oops, something went wrong.