{"_id":"@dyw/vue-bus","_rev":"1-ad260eca3aae53502dda59af3d1f1ad4","name":"@dyw/vue-bus","dist-tags":{"latest":"0.0.1"},"versions":{"0.0.1":{"name":"@dyw/vue-bus","version":"0.0.1","description":"A event bus for Vue.js","main":"dist/vue-bus.common.js","module":"dist/vue-bus.esm.js","unpkg":"dist/vue-bus.js","jsdelivr":"dist/vue-bus.js","typings":"types/index.d.ts","scripts":{"lint":"eslint src __tests__","build":"rimraf dist && rollup -c && uglifyjs dist/vue-bus.js -c -m --comments -o dist/vue-bus.min.js","publish":"npm publish --access public","test":"jest && codecov"},"repository":{"type":"git","url":"git+https://github.com/dyw934854565/vue-bus.git"},"keywords":["vue","events","bus"],"author":{"name":"Yang Mingshan","email":"y.mingshan3@gmail.com"},"license":"MIT","bugs":{"url":"https://github.com/dyw934854565/vue-bus/issues"},"homepage":"https://github.com/dyw934854565/vue-bus#readme","devDependencies":{"buble":"^0.19.7","codecov":"^3.2.0","eslint":"^6.0.1","eslint-config-standard":"^14.1.0","eslint-plugin-import":"^2.16.0","eslint-plugin-node":"^11.0.0","eslint-plugin-promise":"^4.0.1","eslint-plugin-standard":"^4.0.0","jest":"^25.1.0","rimraf":"^3.0.0","rollup":"^2.0.6","rollup-plugin-buble":"^0.19.6","uglify-js":"^3.5.1","vue":"^2.6.10"},"jest":{"coverageDirectory":"./coverage/","testMatch":["**/?(*.)+(spec|test).[jt]s?(x)"],"collectCoverage":true},"gitHead":"8e76b2657c9d1794c83a05b8f4e4cecd447a3415","_id":"@dyw/vue-bus@0.0.1","_nodeVersion":"10.19.0","_npmVersion":"6.13.4","dist":{"integrity":"sha512-QJWe7urELLvd2O0nkFYsWQCNT+vmy2fWwM2UwntyvEMXDOWjvH/Hh08g2XSvi0Qrf/awhfcLvqtxmc5CAMnyTA==","shasum":"1b9e2e3e7bb9106594263186047b6a670c66a4b3","tarball":"https://registry.npmjs.org/@dyw/vue-bus/-/vue-bus-0.0.1.tgz","fileCount":9,"unpackedSize":12377,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJemZBDCRA9TVsSAnZWagAAy0sQAJbXXg5VRnyLwtyE2RHm\n8Z6jfg6sYQds+Y0Vcfrnd/tq1+XX4J1+OeuuPvOnL69gZL/y4lQvD9G0Vuj4\nWFLFDSd+z2mDCXrG+xCNzvlN1B6COgUnVDqX0+xDNdTC96YEvRMiI09RJh4g\ndQZ2tBMuuilAm62NH9/78GtQWj3s4SO0PWjmbxMKgjabrM7gIffqGXTgmzKa\nXSMZS6ix2LJAb8DyOIko5aiCSvYAi28q+u6FB+xiqlYIBsMmw5nv6A0OiMZY\nxr3ys5Q1Owg4q62aEAaqtq++0JuqZywRcm0gr3gUTvSIcMje6X07qfRV4XII\nmbHHeX+RK+JTHOI/EMOnbUwZsRPel3SV3tvLJsZ4sk20nxeIJNqGXMyJlBAn\ngHQRMu7aYIuYUgBfS2WmdCxWDyhQXQBR+QUknDlxaTSOT/oUXMVhvRTPNWtP\nIrp4LCtYULDbHijYGru/U6MbLt/UT+MRrmp04acvJJZG3Y7ZPnSC5niRnU/t\nExLrAALzip9ywxFS3vdoCnl2PSN9hoO3t6KlSvl8PKxuY3mWic5h80nWtEcx\n+aZYcnNdUDFP/UzTd8xZAGIMnU6/FB+bYbtahsiezN1F65ABjMm9Vt8ePh9U\nzFSMhXrxjpVVO91aylpdElV4jvNGHwbV5tG3IVWqgaS58DOrpZlhRfttnrLO\nzKAm\r\n=v6B+\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIDC8LymxyIaN9fOlAneWgYgv3qVJtA0RqLfs3D8XiRP/AiATfVBCJAGooqUmPS1zwQN8tkvhjolFDCgdT+2bwYRCcg=="}]},"maintainers":[{"name":"dyw934854565","email":"dyw934854565@sina.com"}],"_npmUser":{"name":"dyw934854565","email":"dyw934854565@sina.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/vue-bus_0.0.1_1587122243294_0.9893100042457632"},"_hasShrinkwrap":false}},"time":{"created":"2020-04-17T11:17:23.225Z","0.0.1":"2020-04-17T11:17:23.550Z","modified":"2022-04-05T06:19:24.677Z"},"maintainers":[{"name":"dyw934854565","email":"dyw934854565@sina.com"}],"description":"A event bus for Vue.js","homepage":"https://github.com/dyw934854565/vue-bus#readme","keywords":["vue","events","bus"],"repository":{"type":"git","url":"git+https://github.com/dyw934854565/vue-bus.git"},"author":{"name":"Yang Mingshan","email":"y.mingshan3@gmail.com"},"bugs":{"url":"https://github.com/dyw934854565/vue-bus/issues"},"license":"MIT","readme":"# @dyw/vue-bus\n[![Build Status](https://img.shields.io/circleci/project/dyw934854565/vue-bus.svg)](https://circleci.com/gh/dyw934854565/vue-bus)\n[![Coverage Status](https://img.shields.io/codecov/c/github/dyw934854565/vue-bus.svg)](https://codecov.io/gh/dyw934854565/vue-bus)\n[![Downloads](https://img.shields.io/npm/dt/@dyw/vue-bus.svg)](https://www.npmjs.com/package/@dyw/vue-bus)\n[![Version](https://img.shields.io/npm/v/@dyw/vue-bus.svg)](https://www.npmjs.com/package/@dyw/vue-bus)\n[![License](https://img.shields.io/npm/l/@dyw/vue-bus.svg)](https://www.npmjs.com/package/@dyw/vue-bus)\n\nA event bus for Vue.js, support both Vue 1.0 and 2.0. See Vue [documentation](https://vuejs.org/v2/guide/migration.html#Events) for more detail.\n\n## Installation\nYou can install it via [yarn](https://yarnpkg.com) or [npm](https://npmjs.com).\n```\n$ yarn add @dyw/vue-bus\n$ npm install @dyw/vue-bus --save\n```\n\nWhen used with a module system, you must explicitly install the bus via Vue.use():\n```js\nimport Vue from 'vue';\nimport VueBus from '@dyw/vue-bus';\n\nVue.use(VueBus);\n```\nYou don't need to do this when using global script tags.\n\n## Usage\n\n#### 自动在beforeDestroy的时候off，防止内存泄漏\n\n在on和once的时候传入this即可，为了防止内存泄漏，如果用了ts，如果不需要自动off会要求传false\n\n```js\n// ...\ncreated() {\n  this.$bus.on('add-todo', this.addTodo, this);\n  this.$bus.once('once', () => console.log('This listener will only fire once'), this);\n},\nmethods: {\n  addTodo(newTodo) {\n    this.todos.push(newTodo);\n  }\n}\n```\n\n#### Listen and clean\n```js\n// ...\ncreated() {\n  this.$bus.on('add-todo', this.addTodo, false);\n  this.$bus.once('once', () => console.log('This listener will only fire once'), false);\n},\nbeforeDestroy() {\n  this.$bus.off('add-todo', this.addTodo);\n},\nmethods: {\n  addTodo(newTodo) {\n    this.todos.push(newTodo);\n  }\n}\n```\n\n#### Trigger\n```js\n// ...\nmethods: {\n  addTodo() {\n    this.$bus.emit('add-todo', { text: this.newTodoText });\n    this.$bus.emit('once');\n    this.newTodoText = '';\n  }\n}\n```\n#### Another way to use vue-bus\n```js\n// xxx.js\nimport Vue from 'vue';\nimport VueBus from '@dyw/vue-bus';\n\nVue.use(VueBus);\nVue.bus.emit('someEvent');\n```\n*Note: `on` `once` `off` `emit` are aliases for `$on` `$once` `$off` `$emit`. See the [API](https://vuejs.org/v2/api/#Instance-Methods-Events) for more detail.*\n\n## License\n[MIT](https://opensource.org/licenses/MIT)\n","readmeFilename":"README.md"}