File tree Expand file tree Collapse file tree 1 file changed +28
-26
lines changed Expand file tree Collapse file tree 1 file changed +28
-26
lines changed Original file line number Diff line number Diff line change 1- export type Loadable < S > = ILoaded < S > | ILoading | IFailed | IReloading < S > ;
1+ export type Loadable < S > = ILoaded < S > | ILoading | IFailed | IReloading < S >
22
33interface ILoaded < S > {
4- status : "LOADED" ;
5- data : S ;
4+ status : "LOADED"
5+ data : S
66}
77
88interface ILoading {
9- status : "LOADING" ;
9+ status : "LOADING"
1010}
1111
1212interface IReloading < S > {
13- status : "RELOADING" ;
14- data : S ;
13+ status : "RELOADING"
14+ data : S
1515}
1616
1717interface IFailed {
18- status : "FAILED" ;
19- error : Error | string | undefined | null ;
20- message : string | undefined | null ;
18+ status : "FAILED"
19+ error : Error | string | undefined | null
20+ message : string | undefined | null
2121}
2222
2323export const Loading = < S > ( ) : Loadable < S > => ( {
24- status : "LOADING"
25- } ) ;
24+ status : "LOADING" ,
25+ } )
2626export const Reloading = < S > ( s : S ) : Loadable < S > => ( {
27- status : "RELOADING" ,
28- data : s
29- } ) ;
27+ status : "RELOADING" ,
28+ data : s ,
29+ } )
3030export const Loaded = < S > ( s : S ) : Loadable < S > => ( {
31- status : "LOADED" ,
32- data : s
33- } ) ;
31+ status : "LOADED" ,
32+ data : s ,
33+ } )
3434export const Failed = < S > ( e : Error | string | undefined | null , message ?: string | undefined | null ) : Loadable < S > => ( {
35- status : "FAILED" ,
36- error : e ,
37- message
38- } ) ;
35+ status : "FAILED" ,
36+ error : e ,
37+ message,
38+ } )
3939
40- export const isLoaded = < S > ( s : Loadable < S > | undefined | null ) : s is ILoaded < S > => s != null && s . status === "LOADED" ;
41- export const isLoading = < S > ( s ?: Loadable < S > | undefined | null ) : s is ILoading => s == null || s . status === "LOADING" ;
42- export const isReloading = < S > ( s ?: Loadable < S > | undefined | null ) : s is IReloading < S > =>
43- s != null && s . status === "RELOADING" ;
44- export const isFailed = < S > ( s : Loadable < S > | undefined | null ) : s is IFailed => s != null && s . status === "FAILED" ;
40+ type LoadableParam < S > = Loadable < S > | undefined | null
41+
42+ export const isLoaded = < S > ( s : LoadableParam < S > ) : s is ILoaded < S > => s != null && s . status === "LOADED"
43+ export const isLoading = < S > ( s ?: LoadableParam < S > ) : s is ILoading => s == null || s . status === "LOADING"
44+ export const isReloading = < S > ( s ?: LoadableParam < S > ) : s is IReloading < S > =>
45+ s != null && s . status === "RELOADING"
46+ export const isFailed = < S > ( s : LoadableParam < S > ) : s is IFailed => s != null && s . status === "FAILED"
You can’t perform that action at this time.
0 commit comments