vue-bus-ts typescript
Vue-bus-ts is a vue-event-bus plugin that supports typescript
keywords
Vue-event-bus Vue-event Vue-event-bus-ts Vue-event-ts
License
MIT License
Install
npm i -S vue-bus-ts
Usage
#main.ts import Vue from 'vue';import EventBus from 'vue-bus-ts'; Vue.use;var bus = new new Vue.$mount;
$on(action: string, fn: any): any
#*.vue var eventId = this.$bus.$on
$emit(action: string, params?: any): any
#*.vue // params can pass in any form of value, including Array, Object, String, Number, null, undefined or even array expansion items.or example, var eventResult = this.$bus.$emit 1. var result = this.$bus.$emit 2. var result = this.$bus.$emit 3. var result = this.$bus.$emit 4. let a = 1, b = 'test', c = [1, 2, 3], d = {a: 'test'} var result = this.$bus.$emit 5. var result = this.$bus.$emit 6. var result = this.$bus.$emit
$off(action: string, id: number): void
#*.vue this.$bus.$off// To unbind event binding, eventId is the return value of this.$bus.$on
$subscribed(action: string): boolean
#*.vue let result = this.$bus.$subscribed