1
1
mwcMixin = {
2
2
3
3
properties : {
4
- subsReady :{ type :Boolean , value : false } ,
4
+ subsReady :{ type :Boolean , computed : "_subsReady(__handles)" } ,
5
5
mwcData :Object ,
6
6
__handles :{ type :Array , value :[ ] }
7
7
} ,
@@ -19,12 +19,6 @@ mwcMixin = {
19
19
self . __mwcStateDep . depend ( ) ;
20
20
mwcDataUpdate ( self ) ;
21
21
} ) ;
22
- //if no subscriptions are made make subsReady true.
23
- //this is to give user an users an option to subscribe after attaching the element. load spinner only during subscriptions.
24
- if ( ! self . __handles . length ) {
25
- self . set ( "subsReady" , true ) ;
26
- }
27
-
28
22
} ,
29
23
detatched :function ( ) {
30
24
if ( this . __mwcComputation ) {
@@ -35,28 +29,35 @@ mwcMixin = {
35
29
} ,
36
30
subscribe :function ( ) {
37
31
self = this ;
38
- self . __mwcStateDep . depend ( ) ;
39
- self . set ( "subsReady" , false ) ;
40
32
var handle = Meteor . subscribe . apply ( null , arguments ) ;
41
33
var handles = _ . clone ( self . __handles ) ;
42
34
handles . push ( handle ) ;
43
35
self . set ( "__handles" , handles ) ;
44
36
45
- var subsReady = function ( ) {
46
- var isReady = _ . every ( self . __handles , function ( sub ) {
47
- return sub && sub . ready ( ) ;
48
- } ) ;
49
-
50
- return isReady ;
51
- } ;
52
37
Tracker . autorun ( function ( c ) {
53
- if ( subsReady ( ) ) {
54
- self . set ( "subsReady" , true ) ;
55
- c . stop ( ) ;
38
+ try {
39
+ if ( handle . ready ( ) ) {
40
+ self . set ( "__handles" , _ . reject ( _ . clone ( self . __handles ) , function ( h ) {
41
+ return h . subscriptionId = handle . subscriptionId ;
42
+ } ) ) ;
43
+ c . stop ( ) ;
44
+ }
56
45
}
46
+ catch ( err ) {
47
+ console . log ( err ) ;
48
+ }
49
+
57
50
} ) ;
58
51
return handle ;
59
52
} ,
53
+ _subsReady : function ( __h ) {
54
+ var isReady = _ . every ( __h , function ( sub ) {
55
+ return sub && sub . ready ( ) ;
56
+ } ) ;
57
+
58
+ return isReady ;
59
+ } ,
60
+
60
61
getMeteorData :function ( ) {
61
62
}
62
63
} ;
0 commit comments