Correct accidental use of Array.prototype.every on an Object.

Fixes the error reported in the 1.6.1 pull request. (Thanks, @yorrd!)

It's worth nothing that the `DDP._allSubscriptionsReady` function which
was broken is used by the deprecated `spiderable` package.  Since
`spiderable` is deprecated, it's advisable to look into ways to stop
depending on it.

Refs: https://github.com/meteor/meteor/pull/9274#issuecomment-345358178.
This commit is contained in:
Jesse Rosenberger
2017-11-20 13:02:26 +02:00
parent 8e39fd7762
commit 2a62bcac2d

View File

@@ -1,8 +1,14 @@
import { DDPCommon } from 'meteor/ddp-common';
import { Meteor } from 'meteor/meteor';
import { keys } from "meteor/ddp-common/utils.js";
import { Connection } from './livedata_connection.js';
// This array allows the `_allSubscriptionsReady` method below, which
// is used by the `spiderable` package, to keep track of whether all
// data is ready.
const allConnections = [];
/**
* @namespace DDP
* @summary Namespace for DDP-related methods/classes.
@@ -78,11 +84,10 @@ DDP.onReconnect = callback => {
// Hack for `spiderable` package: a way to see if the page is done
// loading all the data it needs.
//
allConnections = [];
DDP._allSubscriptionsReady = () => {
return allConnections.every(conn => {
return conn._subscriptions.every(sub => {
return sub.ready;
return keys(conn._subscriptions).every(id => {
return conn._subscriptions[id].ready;
});
});
};