Page Menu
Home
WickedGov Phorge
Search
Configure Global Search
Log In
Files
F4110561
promisedView.js
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
promisedView.js
View Options
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
;
};
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Tue, Aug 18, 21:53 (1 d, 14 m)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
e2/17/f871258e53197b2a7aee27552d2c
Default Alt Text
promisedView.js (1 KB)
Attached To
Mode
rMWPROD MediaWiki Production
Attached
Detach File
Event Timeline
Log In to Comment