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

Improvements #80

Merged
merged 39 commits into from
Sep 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
1a2a992
Bump terser from 4.8.0 to 4.8.1
dependabot[bot] Jul 21, 2022
e399f43
Bump minimatch from 3.0.4 to 3.1.2
dependabot[bot] Nov 10, 2022
3092bb2
Bump loader-utils from 1.4.0 to 1.4.2
dependabot[bot] Nov 14, 2022
8f02e7f
Bump decode-uri-component from 0.2.0 to 0.2.2
dependabot[bot] Dec 7, 2022
b237b88
Bump qs from 6.5.2 to 6.5.3
dependabot[bot] Dec 12, 2022
e355b5d
Bump json5 from 1.0.1 to 1.0.2
dependabot[bot] Jan 6, 2023
fd857a1
Bump minimist from 1.2.5 to 1.2.8
dependabot[bot] Mar 5, 2023
d6942d7
Fix types definition
mclintprojects Aug 31, 2024
9a39284
Fix #61, #49
mclintprojects Aug 31, 2024
b196f67
Merge pull request #77 from mclintprojects/dependabot/npm_and_yarn/mi…
mclintprojects Aug 31, 2024
9307eec
Merge branch 'chore/improvements' into dependabot/npm_and_yarn/json5-…
mclintprojects Aug 31, 2024
91130a6
Merge pull request #76 from mclintprojects/dependabot/npm_and_yarn/js…
mclintprojects Aug 31, 2024
63330f3
Merge pull request #64 from mclintprojects/dependabot/npm_and_yarn/te…
mclintprojects Aug 31, 2024
7cd5080
Merge pull request #68 from mclintprojects/dependabot/npm_and_yarn/mi…
mclintprojects Aug 31, 2024
3499f8e
Merge branch 'chore/improvements' into dependabot/npm_and_yarn/loader…
mclintprojects Aug 31, 2024
d1fa2f5
Merge pull request #69 from mclintprojects/dependabot/npm_and_yarn/lo…
mclintprojects Aug 31, 2024
8bae7aa
Merge pull request #72 from mclintprojects/dependabot/npm_and_yarn/de…
mclintprojects Aug 31, 2024
e4a55cd
Merge pull request #74 from mclintprojects/dependabot/npm_and_yarn/qs…
mclintprojects Aug 31, 2024
7b22042
Clean up
mclintprojects Aug 31, 2024
f162948
Added support for defineComponent
mclintprojects Aug 31, 2024
f0e6b10
Refactor
mclintprojects Aug 31, 2024
db1a173
Fix tests
mclintprojects Aug 31, 2024
e46b1d9
Refactor
mclintprojects Aug 31, 2024
22372a3
Merge branch 'chore/improvements' of https://github.com/mclintproject…
mclintprojects Aug 31, 2024
4d360ff
Refactor config
mclintprojects Aug 31, 2024
c48f916
Added support for Vue 3 defineComponent
mclintprojects Aug 31, 2024
26e1eca
Cleanup
mclintprojects Aug 31, 2024
d747936
New build
mclintprojects Aug 31, 2024
d77563c
NPM audit fix
mclintprojects Aug 31, 2024
15c31c9
Refactor logger
mclintprojects Aug 31, 2024
6e367bf
Refactor mixin
mclintprojects Aug 31, 2024
067a907
Updated packages
mclintprojects Sep 1, 2024
f6150ea
Updated docs for unsubscribeOnUnmount
mclintprojects Sep 1, 2024
3286717
Updated packages
mclintprojects Sep 1, 2024
c5f781d
Add unsubscribeOnUnmount
mclintprojects Sep 1, 2024
1343a56
Add workflows
mclintprojects Sep 1, 2024
533ea6b
Cleanup
mclintprojects Sep 1, 2024
cd6d688
updated lib
mclintprojects Sep 1, 2024
a621864
3.0.0
mclintprojects Sep 1, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"presets": ["@babel/preset-env"],
"ignore": ["node_modules"],
"plugins": [
"@babel/plugin-proposal-class-properties",
"@babel/plugin-transform-classes"
"presets": [
"@babel/preset-env"
],
"ignore": [
"node_modules"
],
"sourceMaps": true,
"retainLines": true
}
}
1 change: 0 additions & 1 deletion .eslintignore

This file was deleted.

15 changes: 0 additions & 15 deletions .eslintrc.js

This file was deleted.

19 changes: 19 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: CI
on:
push:
branches: master
pull_request:
branches: master
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Install dependencies
uses: borales/[email protected]
with:
cmd: install

- name: Run tests
run: yarn test
15 changes: 1 addition & 14 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,24 +1,11 @@
.DS_Store
node_modules
coverage
# dist

# local env files
.env.local
.env.*.local
*.map

# Log files
npm-debug.log*
yarn-debug.log*
yarn-error.log*
package-lock.json

# Editor directories and files
.bitmap
.idea
.vscode
*.suo
*.ntvs*
*.njsproj
*.sln
.vscode
1 change: 0 additions & 1 deletion .husky/.gitignore

This file was deleted.

4 changes: 0 additions & 4 deletions .husky/pre-commit

This file was deleted.

1 change: 0 additions & 1 deletion .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
src/
tests/
coverage/
.travis.yml
.babelrc
node_modules/
npm-debug.log*
Expand Down
2 changes: 0 additions & 2 deletions .prettierignore

This file was deleted.

5 changes: 0 additions & 5 deletions .prettierrc

This file was deleted.

7 changes: 0 additions & 7 deletions .travis.yml

This file was deleted.

53 changes: 44 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<p align="center">
<a href="https://travis-ci.org/mclintprojects/actioncable-vue"><img src="https://travis-ci.org/mclintprojects/actioncable-vue.svg?branch=master" /></a>
<a href="https://github.com/mclintprojects/actioncable-vue/"><img src="https://github.com/mclintprojects/actioncable-vue/actions/workflows/test.yml/badge.svg" /></a>
<img alt="Last Commit" src="https://badgen.net/github/last-commit/mclintprojects/actioncable-vue" />
<img alt="All Contributors Count" src="https://img.shields.io/github/contributors/mclintprojects/actioncable-vue"/>
<a href="https://www.npmjs.com/package/actioncable-vue"><img src="https://img.shields.io/npm/v/actioncable-vue.svg"/></a>
Expand Down Expand Up @@ -50,6 +50,7 @@ const actionCableVueOptions = {
debugLevel: "error",
connectionUrl: "ws://localhost:5000/api/cable",
connectImmediately: true,
unsubscribeOnUnmount: true,
};

createApp(App)
Expand All @@ -59,13 +60,14 @@ createApp(App)
.mount("#app");
```

| **Parameters** | **Type** | **Default** | **Required** | **Description** |
| ------------------ | --------------- | ----------- | ------------ | ------------------------------------------------------------------------------------------------------------------------------------------------ |
| debug | Boolean | `false` | Optional | Enable logging for debug |
| debugLevel | String | `error` | Optional | Debug level required for logging. Either `info`, `error`, or `all` |
| connectionUrl | String/Function | `null` | Optional | ActionCable websocket server url. Omit it for the [default behavior](https://guides.rubyonrails.org/action_cable_overview.html#connect-consumer) |
| connectImmediately | Boolean | `true` | Optional | ActionCable connects to your server immediately. If false, ActionCable connects on the first subscription. |
| store | Object | null | Optional | Vuex store |
| **Parameters** | **Type** | **Default** | **Required** | **Description** |
| ---------------------| --------------- | ----------- | ------------ | ------------------------------------------------------------------------------------------------------------------------------------------------ |
| debug | Boolean | `false` | Optional | Enable logging for debug |
| debugLevel | String | `error` | Optional | Debug level required for logging. Either `info`, `error`, or `all` |
| connectionUrl | String/Function | `null` | Optional | ActionCable websocket server url. Omit it for the [default behavior](https://guides.rubyonrails.org/action_cable_overview.html#connect-consumer) |
| connectImmediately | Boolean | `true` | Optional | ActionCable connects to your server immediately. If false, ActionCable connects on the first subscription. |
| unsubscribeOnUnmount | Boolean | `true` | Optional | Unsubscribe from channels when component is unmounted. |
| store | Object | null | Optional | Vuex store |

#### Table of content

Expand All @@ -89,7 +91,12 @@ If you'd like to donate to support the continued development and maintenance of

#### 🌈 Component Level Usage

If you want to listen to channel events from your Vue component, you need to either add a `channels` object in the Vue component, or if you're using `vue-class-component` define a `channels` property. Each defined object in `channels` will start to receive events provided you subscribe correctly.
If you want to listen to channel events from your Vue component:
1. You need to either add a `channels` object in the Vue component
2. If you're using `vue-class-component` define a `channels` property.
3. If you're using Vue 3 `defineComponent` define a `channels` property.

Each defined object in `channels` will start to receive events provided you subscribe correctly.

```javascript
new Vue({
Expand Down Expand Up @@ -165,6 +172,34 @@ export default class ChatComponent extends Vue {
}
```

Alternative definition for Vue 3 `defineComponent` users.

```typescript
import { onMounted } from 'vue';

export default defineComponent({
channels: {
ChatChannel: {
connected() {
console.log('connected');
},
rejected() {
console.log('rejected');
},
received(data) {},
disconnected() {},
},
},
setup() {
onMounted(() => {
this.$cable.subscribe({
channel: "ChatChannel",
});
});
},
});
```

#### ✨ Subscriptions

###### 1. Subscribing to a channel
Expand Down
2 changes: 1 addition & 1 deletion dist/actioncablevue.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions jest.setup.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
global.self = global;
53 changes: 17 additions & 36 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "actioncable-vue",
"version": "2.5.1",
"version": "3.0.0",
"description": "A Vue plugin that makes integrating ActionCable easy.",
"main": "dist/actioncablevue.js",
"keywords": [
Expand All @@ -13,17 +13,13 @@
"websocket"
],
"scripts": {
"prepare": "husky install",
"build": "webpack --mode=production --progress --hide-modules",
"build": "webpack --mode=production",
"commit-build": "git add . && git commit -m \"updated lib\"",
"publish-minor": "npm run build && npm run commit-build && npm version minor && npm publish",
"publish-patch": "npm run build && npm run commit-build && npm version patch && npm publish",
"publish-major": "npm run build && npm run commit-build && npm version major && npm publish",
"test": "cross-env VUE_VER=3 jest",
"test-vue2": "cross-env VUE_VER=2 jest",
"format:fix": "prettier --write ./**/*.{js,css,md,vue,ts,json}",
"lint:fix": "eslint --fix ./**/*.{js,vue,ts}",
"lint-staged": "lint-staged"
"test-vue2": "cross-env VUE_VER=2 jest"
},
"files": [
"dist/*.js",
Expand All @@ -41,42 +37,27 @@
},
"homepage": "https://github.com/mclintprojects/actioncable-vue#readme",
"dependencies": {
"@rails/actioncable": "^6.0.2",
"@rails/actioncable": "^7.2.100",
"@types/actioncable": "^5.2.3"
},
"devDependencies": {
"@babel/core": "^7.1.2",
"@babel/plugin-proposal-class-properties": "^7.1.0",
"@babel/plugin-transform-classes": "^7.1.0",
"@babel/preset-env": "^7.1.0",
"@typescript-eslint/eslint-plugin": "^4.29.3",
"@typescript-eslint/parser": "^4.29.3",
"@vue/test-utils": "^1.0.0-beta.28",
"babel-core": "^7.0.0-bridge.0",
"babel-jest": "^25.1.0",
"babel-loader": "^8.0.4",
"@babel/core": "^7.25.2",
"@babel/plugin-transform-class-properties": "^7.25.4",
"@babel/plugin-transform-classes": "^7.25.4",
"@babel/preset-env": "^7.25.4",
"babel-jest": "^29.7.0",
"babel-loader": "^9.1.3",
"cross-env": "^7.0.3",
"eslint": "^7.32.0",
"eslint-config-prettier": "^8.3.0",
"eslint-config-standard": "^16.0.3",
"eslint-plugin-import": "^2.24.2",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-promise": "^5.1.0",
"eslint-plugin-vue": "^7.16.0",
"husky": "^7.0.2",
"jest": "^25.1.0",
"lint-staged": "^11.1.2",
"prettier": "^2.3.2",
"jest": "^29.7.0",
"typescript": "^4.3.5",
"vue": "^3.0.0",
"webpack": "^4.43.0",
"webpack-cli": "^3.3.11"
"webpack": "^5.94.0",
"webpack-cli": "^5.1.4"
},
"jest": {
"testURL": "http://localhost/"
},
"lint-staged": {
"*.{js,vue}": "eslint --fix",
"*.{js,css,md,vue,ts,json}": "prettier --write"
"testURL": "http://localhost/",
"setupFilesAfterEnv": [
"<rootDir>/jest.setup.js"
]
}
}
Loading
Loading