From 9ca82daabba65934affadb8178d02e3429f1db98 Mon Sep 17 00:00:00 2001 From: Nick Martin Date: Sun, 14 Apr 2013 19:17:02 -0700 Subject: [PATCH] Simplify code using new reactive 'ready' function on subscription handles. --- packages/accounts-base/accounts_client.js | 23 +++++------------------ 1 file changed, 5 insertions(+), 18 deletions(-) diff --git a/packages/accounts-base/accounts_client.js b/packages/accounts-base/accounts_client.js index 0fbffec9a6..bc3fdabffe 100644 --- a/packages/accounts-base/accounts_client.js +++ b/packages/accounts-base/accounts_client.js @@ -177,26 +177,13 @@ Meteor.logout = function (callback) { /// LOGIN SERVICES /// -// XXX this can be simplified using the new reactive 'ready' flag on -// subscription handles. -var loginServicesConfigured = false; -var loginServicesConfiguredDeps = new Deps.Dependency; -Meteor.subscribe("meteor.loginServiceConfiguration", function () { - loginServicesConfigured = true; - loginServicesConfiguredDeps.changed(); -}); +var loginServicesHandle = Meteor.subscribe("meteor.loginServiceConfiguration"); -// A reactive function returning whether the -// loginServiceConfiguration subscription is ready. Used by -// accounts-ui to hide the login button until we have all the -// configuration loaded +// A reactive function returning whether the loginServiceConfiguration +// subscription is ready. Used by accounts-ui to hide the login button +// until we have all the configuration loaded Accounts.loginServicesConfigured = function () { - if (loginServicesConfigured) - return true; - - // not yet complete, save the context for invalidation once we are. - loginServicesConfiguredDeps.depend(); - return false; + return loginServicesHandle.ready(); }; ///