Promises are overrated! Too much wiring! Let's simplify:
var scope = { foo: 'foo' };
whenDefined(scope, 'foo', console.log); // outputs 'foo'
whenDefined(scope, 'bar', console.log);
scope.bar = 'bar'; // outputs 'bar'
You can also use this for global variables (though I wouldn't recommend it):
foo = 'foo';
whenDefined('foo', console.log); // outputs 'foo'
whenDefined('bar', console.log);
bar = 'bar'; // outputs 'bar'