@nxtedition/deepstream.io-client-js 23.4.19 → 23.4.20

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nxtedition/deepstream.io-client-js",
3
- "version": "23.4.19",
3
+ "version": "23.4.20",
4
4
  "description": "the javascript client for deepstream.io",
5
5
  "homepage": "http://deepstream.io",
6
6
  "bugs": {
@@ -1,6 +1,6 @@
1
1
  const C = require('../constants/constants')
2
- const rxjs = require('rxjs')
3
2
  const rx = require('rxjs/operators')
3
+ const rxjs = require('rxjs')
4
4
 
5
5
  class Listener {
6
6
  constructor(topic, pattern, callback, handler, { stringify = null, recursive = false } = {}) {
@@ -13,6 +13,25 @@ class Listener {
13
13
  this._subscriptions = new Map()
14
14
  this._stringify = stringify || JSON.stringify
15
15
 
16
+ this._pipe = rxjs.pipe(
17
+ rx.map((value) => {
18
+ let data
19
+ if (value && typeof value === 'string') {
20
+ if (value.charAt(0) !== '{' && value.charAt(0) !== '[') {
21
+ throw new Error(`invalid value: ${value}`)
22
+ }
23
+ data = value
24
+ } else if (value && typeof value === 'object') {
25
+ data = this._stringify(value)
26
+ } else {
27
+ throw new Error(`invalid value: ${value}`)
28
+ }
29
+
30
+ return data
31
+ }),
32
+ rx.distinctUntilChanged()
33
+ )
34
+
16
35
  this._$onConnectionStateChange()
17
36
 
18
37
  if (recursive) {
@@ -59,38 +78,16 @@ class Listener {
59
78
  }
60
79
 
61
80
  if (value$) {
62
- const subscription = value$
63
- .pipe(
64
- rx.map((value) => {
65
- let data
66
- if (value && typeof value === 'string') {
67
- if (value.charAt(0) !== '{' && value.charAt(0) !== '[') {
68
- throw new Error(`invalid value: ${value}`)
69
- }
70
- data = value
71
- } else if (value && typeof value === 'object') {
72
- data = this._stringify(value)
73
- } else {
74
- throw new Error(`invalid value: ${value}`)
75
- }
76
-
77
- return data
78
- }),
79
- rx.distinctUntilChanged()
80
- )
81
- .subscribe({
82
- next: (data) => {
83
- const version = `INF-${this._connection.hasher.h64ToString(data)}`
84
- this._connection.sendMsg(this._topic, C.ACTIONS.UPDATE, [name, version, data])
85
- },
86
- error: (err) => {
87
- this._error(name, err)
88
- this._connection.sendMsg(this._topic, C.ACTIONS.LISTEN_REJECT, [this._pattern, name])
89
- },
90
- complete: () => {
91
- this._connection.sendMsg(this._topic, C.ACTIONS.LISTEN_REJECT, [this._pattern, name])
92
- },
93
- })
81
+ const subscription = value$.subscribe({
82
+ next: (data) => {
83
+ const version = `INF-${this._connection.hasher.h64ToString(data)}`
84
+ this._connection.sendMsg(this._topic, C.ACTIONS.UPDATE, [name, version, data])
85
+ },
86
+ error: (err) => {
87
+ this._error(name, err)
88
+ this._connection.sendMsg(this._topic, C.ACTIONS.LISTEN_REJECT, [this._pattern, name])
89
+ },
90
+ })
94
91
  this._subscriptions.set(name, subscription)
95
92
  } else {
96
93
  this._connection.sendMsg(this._topic, C.ACTIONS.LISTEN_REJECT, [this._pattern, name])