mirror of
https://github.com/tenrok/vue-native-websocket.git
synced 2026-06-06 23:42:26 +03:00
Api updates (#7)
* move all instantiation options into the opts hash * 2.0.0
This commit is contained in:
+2
-2
@@ -3,10 +3,10 @@ import Emitter from './Emitter'
|
||||
|
||||
export default {
|
||||
|
||||
install (Vue, connection, protocol = '', store, opts = {}) {
|
||||
install (Vue, connection, opts = {}) {
|
||||
if (!connection) { throw new Error('[vue-native-socket] cannot locate connection') }
|
||||
|
||||
let observer = new Observer(connection, protocol, store, opts)
|
||||
let observer = new Observer(connection, opts)
|
||||
|
||||
Vue.prototype.$socket = observer.WebSocket
|
||||
|
||||
|
||||
+5
-4
@@ -1,14 +1,15 @@
|
||||
import Emitter from './Emitter'
|
||||
|
||||
export default class {
|
||||
constructor (connectionUrl, protocol, store, opts = {}) {
|
||||
constructor (connectionUrl, opts = {}) {
|
||||
this.format = opts.format && opts.format.toLowerCase()
|
||||
this.connect(connectionUrl, protocol, opts)
|
||||
if (store) { this.store = store }
|
||||
this.connect(connectionUrl, opts)
|
||||
if (opts.store) { this.store = opts.store }
|
||||
this.onEvent()
|
||||
}
|
||||
|
||||
connect (connectionUrl, protocol, opts = {}) {
|
||||
connect (connectionUrl, opts = {}) {
|
||||
let protocol = opts.protocol || ''
|
||||
this.WebSocket = opts.WebSocket || new WebSocket(connectionUrl, protocol)
|
||||
if (this.format === 'json') {
|
||||
if (!('sendObj' in this.WebSocket)) {
|
||||
|
||||
Reference in New Issue
Block a user