Cross post.

---------- Forwarded message ----------
From: Léa Lacroix <lea.lacroix@wikimedia.de>
Date: Tue, Jul 18, 2017 at 4:31 AM
Subject: [Wikidata] wbEntity config variable to be deprecated
To: "Discussion list for the Wikidata project." <wikidata@lists.wikimedia.org>


Hello,

This is an important message for people who develop gadgets or user scripts for Wikidata’s frontend.

We plan to deprecate the wbEntity javascript config variable in the next months. The variable is currently used on every page load, even if when it is not useful (for example on mobile). With that change, we will increase the load speed of the entity pages. After that the expression mw.config.get( 'wbEntity' ); will not work any more. All code that uses this config variable should be migrated towards using the Mediawiki hook wikibase.entityPage.entityLoaded.

When a user opens an entity page (item or property), as soon as the JSON representation of the entity stored on the current entity page is loaded, the Mediawiki hook wikibase.entityPage.entityLoaded is triggered. Listener callbacks should expect the entity as a native JavaScript object (the parsed JSON serialization) passed as the first (and only) argument.

Note: The entity object is completely frozen (read-only) to avoid the case when one of the clients accidentally changes it and breaks other clients.

Here are a few examples on how you can use it:

 // Basic usage
mw.hook( 'wikibase.entityPage.entityLoaded' ).add( function ( entity ) {
  'use strict';
  // Your code goes here
  console.log( entity );
} );

// Convert to jQuery promise
var entityPromise = $.Deferred( function ( deferred ) {
  mw.hook( 'wikibase.entityPage.entityLoaded' ).add( function ( entity ) {
     deferred.resolve( entity );
  } );
} ).promise();

// Convert to native promise
var entityPromise = new Promise( function ( resolve ) {
  mw.hook( 'wikibase.entityPage.entityLoaded' ).add( function ( entity ) {
     resolve( entity );
  } );
} );

See also: the related ticket, the code of wikibase.entityPage.entityLoaded.

If you have any question or need support with migrating specific gadgets, feel free to write to me.
Thanks,

--
Léa Lacroix
Project Manager Community Communication for Wikidata

Wikimedia Deutschland e.V.
Tempelhofer Ufer 23-24
10963 Berlin
www.wikimedia.de

Wikimedia Deutschland - Gesellschaft zur Förderung Freien Wissens e. V.

Eingetragen im Vereinsregister des Amtsgerichts Berlin-Charlottenburg unter der Nummer 23855 Nz. Als gemeinnützig anerkannt durch das Finanzamt für Körperschaften I Berlin, Steuernummer 27/029/42207.

_______________________________________________
Wikidata mailing list
Wikidata@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/wikidata