Page MenuHomePhabricator

Create the PromisedView (name open to change) component!
Closed, ResolvedPublic3 Estimated Story Points


Many of MobileFrontend's Views take an api parameter and invoke api requests during the render process.
This means View's have side effects and are essentially asynchronous smart components. Converting these components to be dumb components has benefits:

  • will lead to them being more reusable. For instance, a list of topics can source data from different API's e.g. talk sections, categories, or even links.
  • they will be more efficient
  • code becomes more readable - no need to track different states of any given view
  • will help us adopt composition patterns
  • encourages separation of app lifecycle code from rendering code
  • view code becomes more about how components look rather than behave

How the PromisedView will help

The common pattern of many of components is as follows:

  • append View to code
  • View requests data from an API
  • View updates itself
  • simplify tests - view tests will no longer need to stub api Requests making tests easier to write! Hurrah!

We will replace this pattern with:

  • append View to code with a placeholder View
  • creator of View fetches data from api
  • when api resolves the placeholder View is replaced with a component created from the data

This will remove all fetch logic from View's and move it upwards to a factory function (in our case this will be inside routes in the OverlayManager.

Suggested reading


Acceptance criteria

  • New component exists
  • New component has 100% code coverage
  • Check component is being used by LanguageOverlay and thus useful.

Event Timeline

Change 469537 had a related patch set uploaded (by Jdlrobson; owner: Jdlrobson):
[mediawiki/extensions/MobileFrontend@master] New components: PromisedView and TopicTitleList component

Change 469537 merged by jenkins-bot:
[mediawiki/extensions/MobileFrontend@master] New component: promisedView

This change didn't change any code so can skip QA and design review. A developer should sign this off and we should verify that this helps support the in progress Talk and Language refactors.

Niedzielski updated the task description. (Show Details)