# vue-use-shared-tick

> Vue 3 hooks run function in same setInterval

Latest version **1.0.0** (published 2023-01-07) · MIT license · 0 weekly downloads

## Install

```sh
npm install vue-use-shared-tick
pnpm add vue-use-shared-tick
yarn add vue-use-shared-tick
bun add vue-use-shared-tick
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2023-01-07 |
| First published | 2023-01-07 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 7.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | ckaznable |

## Links

- npm: https://www.npmjs.com/package/vue-use-shared-tick
- Repository: https://github.com/ckaznable/vue-use-shared-tick
- Issues: https://github.com/ckaznable/vue-use-shared-tick/issues
- npm.io page: https://npm.io/package/vue-use-shared-tick

## Recent versions

- 1.0.0 (latest) — 2023-01-07

## README

# Vue useSharedTick

Vue 3 hook run function in same `setInterval`

## Installation

use npm
```
npm install vue-use-shared-tick --save
```

use yarn
```
yarn add vue-use-shared-tick
```

use pnpm
```
pnpm install vue-use-shared-tick
```

## Usage

run function per second

```vue
<script setup>
import { ref } from "vue"
import useSharedTick from "vue-use-shared-tick"

const time = ref(Date.now())
const onTick = (t) => {
  time.value = t
}

useSharedTick(onTick)
</script>

<template>
  <div>Current Timestamp: {{ time }}</div>
</template>
```

run function per 3 second

```js
useSharedTick(onTick, {tick: 3000})
```

## API

### useSharedTick

```js
useSharedTick(handler: (t: number)=>void, param)
```

### Handler

| Param | Type | Description |
|---|---|---|
|timestamp|`number`|current timestamp|


### Parameter

| Field | Type | Default | Requirement |Description |
|---|:---:|:---:|:---:|:---:|
| tick | `number` | `1000` | `No` | Running interval time |
| runOnTabVisible | `boolean` | `false` | `No` | when true will pause/start interval if `visibilitychange` event dispatched |

## License
The files included in this repository are licensed under the MIT license.

---
_Source: https://npm.io/package/vue-use-shared-tick · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
