mirror of
https://github.com/tenrok/vue-native-websocket.git
synced 2026-06-11 23:22:26 +03:00
Add custom pass to store handler
This commit is contained in:
@@ -12,6 +12,8 @@ export default class {
|
||||
this.reconnectTimeoutId = 0
|
||||
this.reconnectionCount = 0
|
||||
|
||||
this.passToStoreHandler = this.opts.passToStoreHandler || false
|
||||
|
||||
this.connect(connectionUrl, opts)
|
||||
|
||||
if (opts.store) { this.store = opts.store }
|
||||
@@ -61,6 +63,14 @@ export default class {
|
||||
}
|
||||
|
||||
passToStore (eventName, event) {
|
||||
if (this.passToStoreHandler) {
|
||||
this.passToStoreHandler(eventName, event, this.defaultPassToStore)
|
||||
} else {
|
||||
this.defaultPassToStore(eventName, event)
|
||||
}
|
||||
}
|
||||
|
||||
defaultPassToStore (eventName, event) {
|
||||
if (!eventName.startsWith('SOCKET_')) { return }
|
||||
let method = 'commit'
|
||||
let target = eventName.toUpperCase()
|
||||
|
||||
Reference in New Issue
Block a user