import { createSelector } from '@ngxs/store' ; import { MainPageStateModel } from './main.model' ; import { MainPageState } from './main.state' ; export const selectMainTabsList = ( ) => createSelector ( [ MainPageState ] , ( state ) => state . tabs . isLoading ? Array ( 10 ) . fill ( { skeleton : true } ) : state . tabs . listData ) ; export const selectMainTabsLoadingStates = ( ) => createSelector ( [ MainPageState ] , ( state ) => ( { isLoading : state . tabs . isLoading , isSuccess : state . tabs . isSuccess , isFailed : state . tabs . isFailed , } ) ) ; export const selectStories = ( ) => createSelector ( [ MainPageState ] , ( state ) => state . stories . isLoading ? Array ( 10 ) . fill ( { skeleton : true } ) : state . stories . listData ) ; export const selectStoriesLoadingStates = ( ) => createSelector ( [ MainPageState ] , ( state ) => ( { isLoading : state . stories . isLoading , isSuccess : state . stories . isSuccess , isFailed : state . stories . isFailed , } ) ) ; export const selectNews = ( ) => createSelector ( [ MainPageState ] , ( state ) => state . news . pages . map ( ( key ) => state . news . listData [ key ] ) . reduce ( ( a , b ) => a . concat ( b ) , [ ] ) ) ; export const selectNewsIsLoading = ( ) => createSelector ( [ MainPageState ] , ( state ) => state . news . isLoading ) ;