Press n or j to go to the next uncovered block, b, p or k for the previous block.
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 31 32 33 34 35 36 37 38 39 | 1x 1x 1x 4x 4x 4x 2x 2x 2x 1x 1x 1x 4x | const icons = require( './icons' ), View = require( './View' ); /** * Internal for use inside Echo, GrowthExperiments only. * It's a view that spins until the promise resolves! * If the promise successfully resolves, the newView will be shown. if the * promise rejects and rejects to a view, the errorView will be shown. * * @function promisedView * @memberof module:mobile.startup * @param {jQuery.Promise} promise * @return {module:mobile.startup/View} */ module.exports = function promisedView( promise ) { const view = new View( { className: 'promised-view' } ); view.$el.append( icons.spinner().$el ); promise.then( ( newView ) => { view.$el.replaceWith( newView.$el ); // update the internal reference. view.$el = newView.$el; }, ( errorView ) => { if ( !errorView || !errorView.$el ) { // return early to keep backwards compatibility with clients of // promisedView that do not reject to an error view return; } view.$el.replaceWith( errorView.$el ); // update the internal reference. view.$el = errorView.$el; } ); return view; }; |