Tee tracked events to MediaWiki's mw.track

When running in the context of MediaWiki, VisualEditor should tee its event
stream to MediaWiki's main event bus, mw.track(), so that MediaWiki event
subscribers have a unified interface for subscribing to events. Each
VisualEditor event topic is prefixed with 've.'

To test this patch, you can use this snippet:

  mw.trackSubscribe( 've', function ( topic, data ) {
    console.log( this, topic, data );
  } );

Change-Id: I6b3f10b0dd0aa7fa47c3b35e2fc554622960ce52
This commit is contained in:
Ori Livneh 2014-01-16 12:33:14 -08:00
parent 8e7a864e90
commit 753d87e618

View file

@ -36,6 +36,13 @@
var target = new ve.init.mw.ViewPageTarget();
ve.init.mw.targets.push( target );
// Tee tracked events to MediaWiki firehose, if available (1.23+).
if ( mw.track ) {
ve.trackSubscribeAll( function ( topic, data ) {
mw.track.call( null, 've.' + topic, data );
} );
}
// Transfer methods
ve.init.mw.ViewPageTarget.prototype.setupSectionEditLinks = init.setupSectionLinks;