Page MenuHomePhabricator

Replace anonymous functions returned by Pinia getters with named functions to help with profiling
Closed, ResolvedPublic

Description

Description

Browser profiling lacks relevant information when getters return anonymous functions. For the sake of profiling, we should return named functions instead.

Getter returned functions were named with Vuex but this was changed on the Vuex->Pinia migration.


Completion checklist

Event Timeline

If we encounter debugging in profiler to be hard.
The possible solutions are:

isWikidataFetch: function () {
  /**
   * @param {number} rowId
   * @return {boolean}
   */
  const  isWikidataFetchByRowId = (rowId)  => {
    const functionCallFunction = this.getZFunctionCallFunctionId(rowId);
   // code...
  };
  return isWikidataFetchByRowId;
},

//OR

isWikidataFetch: function () {
const self = this
  /**
   * @param {number} rowId
   * @return {boolean}
   */
  return function isWikidataFetchByRowId(rowId) {
    const functionCallFunction = self.getZFunctionCallFunctionId(rowId);
   // code...
  };
},

// OR

isWikidataFetch: function () {
  /**
   * @param {number} rowId
   * @return {boolean}
   */
  function isWikidataFetchByRowId(rowId) {
    const functionCallFunction = this.getZFunctionCallFunctionId(rowId);
   // code...
  }
  return isWikidataFetchByRowId.bind(this);
},

Change #1122943 had a related patch set uploaded (by Daphne Smit; author: Daphne Smit):

[mediawiki/extensions/WikiLambda@master] Pinia Store: Replace anonymous functions returned by Pinia getters with named functions to help with profiling

https://gerrit.wikimedia.org/r/1122943

Change #1122943 merged by jenkins-bot:

[mediawiki/extensions/WikiLambda@master] Pinia Store: Replace anonymous functions returned by Pinia getters with named functions to help with profiling

https://gerrit.wikimedia.org/r/1122943