Slaying a UI Antipattern with Angular

The example

Example application

The Boolean approach

  • isLoading: It‘s true while the remote data is being fetched.
  • error: It‘s either null (no errors) or any string (there are errors).
  • data: It’s either null (no data) or an object (there is data).
{
isLoading: true,
error: 'Fatal error',
data: {}
}

The RemoteData approach

state: RemoteData<string, ServiceResult> = new NotAsked();

Recap

--

--

--

Web developer • λ • Barcelona

Love podcasts or audiobooks? Learn on the go with our new app.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Joan Llenas Masó

Joan Llenas Masó

Web developer • λ • Barcelona

More from Medium

Creating a Singleton service in Angular

How to Test Chart.js in an Angular Component

How to start with NX and Angular?

Cypress Library e2e with Angular Project