Skip to content

Instantly share code, notes, and snippets.

@joanllenas
Created February 11, 2018 23:58
Show Gist options
  • Save joanllenas/705eb25703efef02671ba1d012d7eefc to your computer and use it in GitHub Desktop.
Save joanllenas/705eb25703efef02671ba1d012d7eefc to your computer and use it in GitHub Desktop.
RemoteData approach - Slaying a UI Antipattern with Angular
export class NotAsked {}
export class Loading {}
export class Faliure<E> {
constructor(private error: E){}
fold(): E {
return this.error;
}
}
export class Success<T> {
constructor(private value: T){}
fold(): T {
return this.value;
}
}
export type RemoteData<E, T> = NotAsked | Loading | Faliure<E> | Success<T>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment