-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathspiderable_client.js
30 lines (26 loc) · 1.24 KB
/
spiderable_client.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
// We want to provide a deteriministic indicator of when the page is 'done'
// This is non-trivial: e.g. an infinite stream of tweets is never done.
//
// We do this instead:
// We are done sometime after all initial subscriptions are ready
// Initial subscriptions are those started in the top-level script execution,
// or from a Meteor.startup callback when Meteor.startup is called in
// top-level script execution.
//
// Note that we don't guarantee that we won't wait longer than we have to;
// extra subscriptions may be made, and extra data past the minimum may be
// received.
//
// We set this 'started' flag as Package.spiderable.Spiderable._initialSubscriptionsStarted
// This is used by our phantomjs to determine when the subscriptions are started;
// it then polls until all subscriptions are ready.
Spiderable._initialSubscriptionsStarted = false;
var startupCallbacksDone = function () {
Spiderable._initialSubscriptionsStarted = true;
};
// This extra indirection is how we get called last
var topLevelCodeDone = function () {
// We'd like to use Meteor.startup here I think, but docs/behaviour of that is wrong
Meteor._setImmediate(function () { startupCallbacksDone(); });
};
Meteor.startup(function () { topLevelCodeDone(); });