Skip to content

Commit d2e8f42

Browse files
authored
Merge pull request #2 from srav001/0.0.4
0.0.4
2 parents 8ea9bbb + dc6de8b commit d2e8f42

19 files changed

+605
-81
lines changed
File renamed without changes.

README.md

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,26 @@
11
# vue-subscription
22

3+
A type-safe 🔥, tiny ⭐️ & fast ⚡️ replacement for EventBus in Vue 💚. Provides ESM and Common JS exports. Compatible with Vue versions `>=2.7.0` or `3.0.0`.
4+
35
This Vue package provides a simple way to create reactive subscriptions that can be used to observe changes to a value and execute a list of subscribers when the value changes. It also includes methods to mutate the value and trigger subscribers manually.
46

57
The `useSubscription` function takes an initial value and returns an object with a reactive value of the initial value passed in, and a subscriber can be added to be executed when the value is changed.
68

7-
---
8-
99
## Installation and Import
1010

1111
To use this package, you can install it via npm:
1212

1313
```sh
1414
// In your console
15-
npm install @vue-subscription
15+
npm install vue-subscription
1616
```
1717

1818
```typescript
1919
// In your file
20-
import { useSubscription } from '@vue-subscription';
20+
import { useSubscription } from 'vue-subscription';
2121
const $mySubscription = useSubscription('hello'); // Type will be string
2222
```
2323

24-
---
25-
2624
## API
2725

2826
### $value / $get()
@@ -98,8 +96,6 @@ subscription.$mutate(value => {
9896
});
9997
```
10098

101-
---
102-
10399
## Usage
104100

105101
### Basic Example
@@ -202,8 +198,6 @@ $set(val => `Hello ${val}`);
202198
console.log($read.value); // 'Hello world'
203199
```
204200

205-
---
206-
207201
## Type definition
208202

209203
### Function Signature
@@ -239,3 +233,8 @@ An object with the following properties:
239233
- $deleteSub(subscriber: (value: T) => Promise<void> | void)) - A method for removing a subscriber from the subscription.
240234
- $triggerSubs() - A method for manually triggering all subscribers. This should rarely be necessary.
241235
- $mutate(mutator: (value: T) => T) - A method for updating the value of the subscription with a function that takes the current value as its argument and returns the new value. This should only be used for updating complex objects.
236+
237+
## DEMO
238+
239+
You can checkout the demo to test locally or on StackBlitz
240+
https://github.com/srav001/vue-subscription/tree/main/demo
File renamed without changes.

index.cjs

Whitespace-only changes.

package.json

Lines changed: 68 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,69 @@
11
{
2-
"name": "vue-subscription",
3-
"version": "0.0.1",
4-
"description": "A simple ⭐️ & type-safe 🔥 replacement for EventBus in Vue 💚.",
5-
"main": "index.js",
6-
"scripts": {
7-
"dev": "vite",
8-
"preview": "vite preview",
9-
"build-only": "vite build",
10-
"type-check": "vue-tsc --noEmit",
11-
"build": "pnpm type-check && pnpm build-only",
12-
"pre-push": "pnpm format && pnpm lint && pnpm build",
13-
"lint": "node -e 'require(\"./scripts\").lint()'",
14-
"format": "node -e 'require(\"./scripts\").format()'",
15-
"project-setup": "node -e 'require(\"./scripts\").projectSetup()'"
16-
},
17-
"repository": {
18-
"type": "git",
19-
"url": "git+https://github.com/srav001/vue-subscription.git"
20-
},
21-
"author": "",
22-
"license": "MIT",
23-
"bugs": {
24-
"url": "https://github.com/srav001/vue-subscription/issues"
25-
},
26-
"homepage": "https://github.com/srav001/vue-subscription#readme",
27-
"peerDependencies": {
28-
"vue": ">=^2.7.0 || ^3.0.0"
29-
},
30-
"devDependencies": {
31-
"@commitlint/cli": "^17.4.4",
32-
"@commitlint/config-conventional": "^17.4.4",
33-
"@types/node": "^18.14.2",
34-
"@total-typescript/ts-reset": "^0.3.7",
35-
"@typescript-eslint/eslint-plugin": "^5.54.0",
36-
"@typescript-eslint/parser": "^5.54.0",
37-
"@vitejs/plugin-vue": "^4.0.0",
38-
"@vue/eslint-config-prettier": "^7.1.0",
39-
"@vue/eslint-config-typescript": "^11.0.2",
40-
"@vue/tsconfig": "^0.1.3",
41-
"eslint": "^8.34.0",
42-
"eslint-plugin-sonarjs": "^0.18.0",
43-
"eslint-plugin-vue": "^9.9.0",
44-
"husky": "^8.0.3",
45-
"prettier": "^2.8.4",
46-
"typescript": "~4.9.4",
47-
"vite": "^4.1.4",
48-
"vue": "^3.2.47",
49-
"vue-tsc": "^1.2.0"
50-
},
51-
"engines": {
52-
"node": ">=16.0.0",
53-
"pnpm": ">=6.0.0"
54-
}
55-
}
2+
"name": "vue-subscription",
3+
"version": "0.0.4",
4+
"description": "A simple ⭐️ & type-safe 🔥 replacement for EventBus in Vue 💚.",
5+
"scripts": {
6+
"dev": "vite",
7+
"preview": "vite preview",
8+
"build-only": "vite build",
9+
"type-check": "vue-tsc --noEmit",
10+
"lint": "node -e 'require(\"./scripts.cjs\").lint()'",
11+
"format": "node -e 'require(\"./scripts.cjs\").format()'",
12+
"build": "pnpm type-check && pnpm build-only",
13+
"pre-push": "pnpm format && pnpm lint && pnpm build",
14+
"release": "node -e 'require(\"./scripts.cjs\").release()'",
15+
"project-setup": "node -e 'require(\"./scripts.cjs\").projectSetup()'"
16+
},
17+
"type": "module",
18+
"main": "./dist/vue-subscription.umd.cjs",
19+
"module": "./dist/vue-subscription.js",
20+
"types": "./dist/index.d.ts",
21+
"exports": {
22+
".": {
23+
"import": "./dist/vue-subscription.js",
24+
"require": "./dist/vue-subscription.umd.cjs"
25+
}
26+
},
27+
"files": [
28+
"dist"
29+
],
30+
"repository": {
31+
"type": "git",
32+
"url": "git+https://github.com/srav001/vue-subscription.git"
33+
},
34+
"author": "",
35+
"license": "MIT",
36+
"bugs": {
37+
"url": "https://github.com/srav001/vue-subscription/issues"
38+
},
39+
"homepage": "https://github.com/srav001/vue-subscription#readme",
40+
"peerDependencies": {
41+
"vue": ">=^2.7.0 || ^3.0.0"
42+
},
43+
"devDependencies": {
44+
"@commitlint/cli": "^17.4.4",
45+
"@commitlint/config-conventional": "^17.4.4",
46+
"@total-typescript/ts-reset": "^0.3.7",
47+
"@types/node": "^18.14.2",
48+
"@typescript-eslint/eslint-plugin": "^5.54.0",
49+
"@typescript-eslint/parser": "^5.54.0",
50+
"@vitejs/plugin-vue": "^4.0.0",
51+
"@vue/eslint-config-prettier": "^7.1.0",
52+
"@vue/eslint-config-typescript": "^11.0.2",
53+
"@vue/tsconfig": "^0.1.3",
54+
"eslint": "^8.34.0",
55+
"eslint-plugin-sonarjs": "^0.18.0",
56+
"eslint-plugin-vue": "^9.9.0",
57+
"husky": "^8.0.3",
58+
"prettier": "^2.8.4",
59+
"typescript": "~4.9.4",
60+
"vite": "^4.1.4",
61+
"vite-plugin-dts": "^2.1.0",
62+
"vue": "^3.2.47",
63+
"vue-tsc": "^1.2.0"
64+
},
65+
"engines": {
66+
"node": ">=16.0.0",
67+
"pnpm": ">=6.0.0"
68+
}
69+
}

0 commit comments

Comments
 (0)