Created
February 11, 2018 23:58
-
-
Save joanllenas/705eb25703efef02671ba1d012d7eefc to your computer and use it in GitHub Desktop.
RemoteData approach - Slaying a UI Antipattern with Angular
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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