jenkins-bot has submitted this change and it was merged.

Change subject: Add a mechanism to wait until ve.init.platform has been created
......................................................................


Add a mechanism to wait until ve.init.platform has been created

The VE-MW code is careful to create ve.init.platform before loading
the bulk of the VE code, but standalone VE (and the unit tests) assumes
that creating ve.init.platform is the *last* thing done, after all the
VE code is loaded.  Create a mechanism to allow bits of initialization
to wait if needed until ve.init.platform has been created and initialized.

Needed by I21976ce0cc823af29bdd2a5c163476fea2408488.

Change-Id: I3c64c1d396a67ba3b3bc4e3d4c320b750663f40a
---
M src/init/ve.init.Platform.js
1 file changed, 27 insertions(+), 0 deletions(-)

Approvals:
  Alex Monk: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/src/init/ve.init.Platform.js b/src/init/ve.init.Platform.js
index 563b4c1..14cd008 100644
--- a/src/init/ve.init.Platform.js
+++ b/src/init/ve.init.Platform.js
@@ -22,12 +22,39 @@
        // Provide messages to OOUI
        OO.ui.getUserLanguages = this.getUserLanguages.bind( this );
        OO.ui.msg = this.getMessage.bind( this );
+
+       // Notify those waiting for a platform that they can finish 
initialization
+       setTimeout( function () {
+               ve.init.Platform.static.deferredPlatform.resolve( 
ve.init.platform );
+       } );
 };
 
 /* Inheritance */
 
 OO.mixinClass( ve.init.Platform, OO.EventEmitter );
 
+/* Static Properties */
+
+/**
+ * A jQuery.Deferred that tracks when the platform has been created.
+ * @private
+ */
+ve.init.Platform.static.deferredPlatform = $.Deferred();
+
+/**
+ * A promise that tracks when ve.init.platform is ready for use.  When
+ * this promise is resolved the platform will have been created and
+ * initialized.
+ *
+ * This promise is safe to access early in VE startup before
+ * `ve.init.platform` has been set.
+ *
+ * @property {jQuery.Promise}
+ */
+ve.init.Platform.static.initializedPromise = 
ve.init.Platform.static.deferredPlatform.promise().then( function ( platform ) {
+       return platform.getInitializedPromise();
+} );
+
 /* Static Methods */
 
 /**

-- 
To view, visit https://gerrit.wikimedia.org/r/230489
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I3c64c1d396a67ba3b3bc4e3d4c320b750663f40a
Gerrit-PatchSet: 3
Gerrit-Project: VisualEditor/VisualEditor
Gerrit-Branch: master
Gerrit-Owner: Cscott <[email protected]>
Gerrit-Reviewer: Alex Monk <[email protected]>
Gerrit-Reviewer: Catrope <[email protected]>
Gerrit-Reviewer: Esanders <[email protected]>
Gerrit-Reviewer: Krinkle <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to