@nxtedition/deepstream.io-client-js 23.4.18 → 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.18",
3
+ "version": "23.4.20",
4
4
  "description": "the javascript client for deepstream.io",
5
5
  "homepage": "http://deepstream.io",
6
6
  "bugs": {
@@ -1,4 +1,5 @@
1
1
  const C = require('../constants/constants')
2
+ const rx = require('rxjs/operators')
2
3
  const rxjs = require('rxjs')
3
4
 
4
5
  class Listener {
@@ -12,6 +13,25 @@ class Listener {
12
13
  this._subscriptions = new Map()
13
14
  this._stringify = stringify || JSON.stringify
14
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
+
15
35
  this._$onConnectionStateChange()
16
36
 
17
37
  if (recursive) {
@@ -58,38 +78,16 @@ class Listener {
58
78
  }
59
79
 
60
80
  if (value$) {
61
- const subscription = value$
62
- .pipe(
63
- rxjs.map((value) => {
64
- let data
65
- if (value && typeof value === 'string') {
66
- if (value.charAt(0) !== '{' && value.charAt(0) !== '[') {
67
- throw new Error(`invalid value: ${value}`)
68
- }
69
- data = value
70
- } else if (value && typeof value === 'object') {
71
- data = this._stringify(value)
72
- } else {
73
- throw new Error(`invalid value: ${value}`)
74
- }
75
-
76
- return data
77
- }),
78
- rxjs.distinctUntilChanged()
79
- )
80
- .subscribe({
81
- next: (data) => {
82
- const version = `INF-${this._connection.hasher.h64ToString(data)}`
83
- this._connection.sendMsg(this._topic, C.ACTIONS.UPDATE, [name, version, data])
84
- },
85
- error: (err) => {
86
- this._error(name, err)
87
- this._connection.sendMsg(this._topic, C.ACTIONS.LISTEN_REJECT, [this._pattern, name])
88
- },
89
- complete: () => {
90
- this._connection.sendMsg(this._topic, C.ACTIONS.LISTEN_REJECT, [this._pattern, name])
91
- },
92
- })
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
+ })
93
91
  this._subscriptions.set(name, subscription)
94
92
  } else {
95
93
  this._connection.sendMsg(this._topic, C.ACTIONS.LISTEN_REJECT, [this._pattern, name])