You've already forked matrix-js-sdk
mirror of
https://github.com/matrix-org/matrix-js-sdk.git
synced 2026-01-03 23:22:30 +03:00
Use once to clean up listener
This commit is contained in:
@@ -13,9 +13,14 @@ const MatrixEvent = sdk.MatrixEvent;
|
||||
*/
|
||||
module.exports.syncPromise = function(client) {
|
||||
const def = q.defer();
|
||||
client.on('sync', (state) => {
|
||||
if (state == 'SYNCING') def.resolve();
|
||||
});
|
||||
const cb = (state) => {
|
||||
if (state == 'SYNCING') {
|
||||
def.resolve();
|
||||
} else {
|
||||
client.once('sync', cb);
|
||||
}
|
||||
};
|
||||
client.once('sync', cb);
|
||||
return def.promise;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user