Skip to content

Commit

Permalink
Merge pull request #58 from dhershman1/development
Browse files Browse the repository at this point in the history
Development v3.0.1
  • Loading branch information
dhershman1 authored Jul 23, 2021
2 parents 0963380 + adb05ba commit a9d3028
Show file tree
Hide file tree
Showing 8 changed files with 75 additions and 19 deletions.
29 changes: 29 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
---
name: Bug report
about: Create a report to help vue-debounce improve

---

**Describe the bug**
A clear and concise description of what the bug is.

**Version of Vue**
Which version of vue are you on? (2 or 3)

**To Reproduce**
Steps to reproduce the behavior:
1. Go to '...'
2. Pass it '...'
3. See error

**Expected behavior**
A clear and concise description of what you expected to happen.

**Desktop (please complete the following information):**
- Browser [e.g. chrome, safari, node]

**Screenshots**
If applicable/needed, add screenshots to help explain your problem.

**Additional context**
Add any other context about the problem here. (If none needed feel free to remove this section)
13 changes: 13 additions & 0 deletions .github/ISSUE_TEMPLATE/question.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
name: Question
about: Unsure of how to use something or just need general help?

---

**Version of Vue**
Which version of vue are you using?

**Browser**
What browser are you using?

Type out the question to the best of your ability!
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
.DS_Store

test.html
test-func.html
test-vue3.html

dist/
Expand Down
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Change Log

## v3.0.1

### Improved

- Types for debounce (thanks to [hrobertson](https://github.com/hrobertson))
- Placement of the readme for `getDirective`

## v3.0.0

### BREAKING CHANGES
Expand Down
32 changes: 19 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,25 @@ This function takes in 2 arguments, they are:
- 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

```js
import { getDirective } from 'vue-debounce'

const component = {
directives: {
// Please see above for arguments you can pass to this function
debounce: getDirective()
}
}

// If you are using vue 3 you MUST tell the function this by passing in the first argument
const component = {
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)
}
}
```

## Usage

First make sure we tell vue to use it
Expand Down Expand Up @@ -113,19 +132,6 @@ Vue.use(vueDebounce, {
})
```

You can also attach the directive at a component level as of v3:

```js
import { getDirective } from 'vue-debounce'

const component = {
directives: {
// Please see above for arguments you can pass to this function
debounce: getDirective()
}
}
```

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:
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "vue-debounce",
"version": "3.0.0",
"version": "3.0.1",
"description": "A simple vue directive for debounce",
"main": "dist/vue-debounce.min.js",
"types": "types/index.d.ts",
Expand All @@ -10,7 +10,7 @@
"build": "rollup -c",
"watch": "rollup -c -w",
"lint": "standard src/*.js",
"linit:fix": "standard --fix src/*.js"
"lint:fix": "standard --fix src/*.js"
},
"standard": {
"ignore": [
Expand Down
6 changes: 3 additions & 3 deletions types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ interface GetDirective {
(version?: string, opts?: PluginConfig): DirectiveObject
}

interface DebounceInstance {
(): void,
interface DebounceInstance<A extends unknown[]> {
(...args: A): void,
cancel(): void,
}

interface Debounce {
(fn: (...args: any[]) => void, wait: number | string): DebounceInstance
<A extends unknown[]>(fn: (...args: A) => void, wait: number | string): DebounceInstance<A>
}

declare const debounce: Debounce
Expand Down

0 comments on commit a9d3028

Please sign in to comment.