Skip to content

Commit a0a4e43

Browse files
committed
refactor(livequery): subscribe after connecting to RTM
1 parent 3e852ff commit a0a4e43

File tree

1 file changed

+19
-18
lines changed

1 file changed

+19
-18
lines changed

src/live-query.js

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -98,25 +98,26 @@ module.exports = AV => {
9898
throw new TypeError('LiveQuery must be inited with a Query');
9999
const { where, keys, returnACL } = query.toJSON();
100100
return Promise.resolve(userDefinedSubscriptionId).then(subscriptionId =>
101-
request({
102-
method: 'POST',
103-
path: '/LiveQuery/subscribe',
104-
data: {
105-
query: {
106-
where,
107-
keys,
108-
returnACL,
109-
className: query.className,
110-
},
111-
id: subscriptionId,
112-
},
113-
}).then(({ query_id: queryId }) =>
114-
AV._config.realtime
115-
.createLiveQueryClient(subscriptionId)
116-
.then(
117-
liveQueryClient => new AV.LiveQuery(queryId, liveQueryClient)
101+
AV._config.realtime
102+
.createLiveQueryClient(subscriptionId)
103+
.then(liveQueryClient =>
104+
request({
105+
method: 'POST',
106+
path: '/LiveQuery/subscribe',
107+
data: {
108+
query: {
109+
where,
110+
keys,
111+
returnACL,
112+
className: query.className,
113+
},
114+
id: subscriptionId,
115+
},
116+
}).then(
117+
({ query_id: queryId }) =>
118+
new AV.LiveQuery(queryId, liveQueryClient)
118119
)
119-
)
120+
)
120121
);
121122
},
122123
}

0 commit comments

Comments
 (0)