@@ -38,6 +38,7 @@ export class RxReplicationState {
38
38
this . _subjects = {
39
39
change : new Subject ( ) ,
40
40
docs : new Subject ( ) ,
41
+ denied : new Subject ( ) ,
41
42
active : new BehaviorSubject ( false ) ,
42
43
complete : new BehaviorSubject ( false ) ,
43
44
error : new Subject ( ) ,
@@ -46,7 +47,7 @@ export class RxReplicationState {
46
47
// create getters
47
48
Object . keys ( this . _subjects ) . forEach ( key => {
48
49
Object . defineProperty ( this , key + '$' , {
49
- get : function ( ) {
50
+ get : function ( ) {
50
51
return this . _subjects [ key ] . asObservable ( ) ;
51
52
}
52
53
} ) ;
@@ -60,54 +61,60 @@ export class RxReplicationState {
60
61
// change
61
62
this . _subs . push (
62
63
fromEvent ( evEmitter , 'change' )
63
- . subscribe ( ev => this . _subjects . change . next ( ev ) )
64
+ . subscribe ( ev => this . _subjects . change . next ( ev ) )
65
+ ) ;
66
+
67
+ // denied
68
+ this . _subs . push (
69
+ fromEvent ( evEmitter , 'denied' )
70
+ . subscribe ( ev => this . _subjects . denied . next ( ev ) )
64
71
) ;
65
72
66
73
// docs
67
74
this . _subs . push (
68
75
fromEvent ( evEmitter , 'change' )
69
- . subscribe ( ev => {
70
- if (
71
- this . _subjects . docs . observers . length === 0 ||
72
- ev . direction !== 'pull'
73
- ) return ;
74
-
75
- ev . change . docs
76
- . filter ( doc => doc . language !== 'query' ) // remove internal docs
77
- . map ( doc => this . collection . _handleFromPouch ( doc ) ) // do primary-swap and keycompression
78
- . forEach ( doc => this . _subjects . docs . next ( doc ) ) ;
79
- } ) ) ;
76
+ . subscribe ( ev => {
77
+ if (
78
+ this . _subjects . docs . observers . length === 0 ||
79
+ ev . direction !== 'pull'
80
+ ) return ;
81
+
82
+ ev . change . docs
83
+ . filter ( doc => doc . language !== 'query' ) // remove internal docs
84
+ . map ( doc => this . collection . _handleFromPouch ( doc ) ) // do primary-swap and keycompression
85
+ . forEach ( doc => this . _subjects . docs . next ( doc ) ) ;
86
+ } ) ) ;
80
87
81
88
// error
82
89
this . _subs . push (
83
90
fromEvent ( evEmitter , 'error' )
84
- . subscribe ( ev => this . _subjects . error . next ( ev ) )
91
+ . subscribe ( ev => this . _subjects . error . next ( ev ) )
85
92
) ;
86
93
87
94
// active
88
95
this . _subs . push (
89
96
fromEvent ( evEmitter , 'active' )
90
- . subscribe ( ( ) => this . _subjects . active . next ( true ) )
97
+ . subscribe ( ( ) => this . _subjects . active . next ( true ) )
91
98
) ;
92
99
this . _subs . push (
93
100
fromEvent ( evEmitter , 'paused' )
94
- . subscribe ( ( ) => this . _subjects . active . next ( false ) )
101
+ . subscribe ( ( ) => this . _subjects . active . next ( false ) )
95
102
) ;
96
103
97
104
// complete
98
105
this . _subs . push (
99
106
fromEvent ( evEmitter , 'complete' )
100
- . subscribe ( info => {
107
+ . subscribe ( info => {
101
108
102
- /**
103
- * when complete fires, it might be that not all changeEvents
104
- * have passed throught, because of the delay of .wachtForChanges()
105
- * Therefore we have to first ensure that all previous changeEvents have been handled
106
- */
107
- const unhandledEvents = Array . from ( this . collection . _watchForChangesUnhandled ) ;
109
+ /**
110
+ * when complete fires, it might be that not all changeEvents
111
+ * have passed throught, because of the delay of .wachtForChanges()
112
+ * Therefore we have to first ensure that all previous changeEvents have been handled
113
+ */
114
+ const unhandledEvents = Array . from ( this . collection . _watchForChangesUnhandled ) ;
108
115
109
- Promise . all ( unhandledEvents ) . then ( ( ) => this . _subjects . complete . next ( info ) ) ;
110
- } )
116
+ Promise . all ( unhandledEvents ) . then ( ( ) => this . _subjects . complete . next ( info ) ) ;
117
+ } )
111
118
) ;
112
119
}
113
120
@@ -252,7 +259,7 @@ export const prototypes = {
252
259
export const overwritable = { } ;
253
260
254
261
export const hooks = {
255
- createRxCollection : function ( collection ) {
262
+ createRxCollection : function ( collection ) {
256
263
INTERNAL_POUCHDBS . add ( collection . pouch ) ;
257
264
}
258
265
} ;
0 commit comments