Cscott has uploaded a new change for review.
https://gerrit.wikimedia.org/r/230489
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(-)
git pull ssh://gerrit.wikimedia.org:29418/VisualEditor/VisualEditor
refs/changes/89/230489/1
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: newchange
Gerrit-Change-Id: I3c64c1d396a67ba3b3bc4e3d4c320b750663f40a
Gerrit-PatchSet: 1
Gerrit-Project: VisualEditor/VisualEditor
Gerrit-Branch: master
Gerrit-Owner: Cscott <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits