當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript redux-typed.isActionType函數代碼示例

本文整理匯總了TypeScript中redux-typed.isActionType函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript isActionType函數的具體用法?TypeScript isActionType怎麽用?TypeScript isActionType使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了isActionType函數的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: if

export const reducer: Reducer<GenreDetailsState> = (state, action) => {
    if (isActionType(action, RequestGenreDetails)) {
        return { requestedGenreId: action.genreId, albums: [], isLoaded: false };
    } else if (isActionType(action, ReceiveGenreDetails)) {
        return { requestedGenreId: action.genreId, albums: action.albums, isLoaded: true };
    } else {
        return state || { requestedGenreId: null as number, albums: [], isLoaded: false };
    }
};
開發者ID:Naveen-Bhat,項目名稱:NodeServices,代碼行數:9,代碼來源:GenreDetails.ts

示例2: if

export const reducer: Reducer<AlbumDetailsState> = (state, action) => {
    if (isActionType(action, RequestAlbumDetails)) {
        return { requestedAlbumId: action.albumId, album: null };
    } else if (isActionType(action, ReceiveAlbumDetails)) {
        return { requestedAlbumId: action.album.AlbumId, album: action.album };
    } else {
        return state || unloadedState;
    }
};
開發者ID:Naveen-Bhat,項目名稱:NodeServices,代碼行數:9,代碼來源:AlbumDetails.ts

示例3: if

export const reducer: Reducer<UsersState> = (state, action) => {
    if (isActionType(action, UserLoad)) {
        return { isLoading: true, users: state.users, user:state.user };
    } else if (isActionType(action, UserList)) {
            return {users: action.users, user:state.user, isLoading: false };
    }else if (isActionType(action, UserItem)) {
        return {users: state.users, user: action.user, isLoading: false };
    }
    return state || unloadedState;
};
開發者ID:AaronJin2013,項目名稱:react-frame-demo,代碼行數:10,代碼來源:index.ts

示例4:

export const reducer: Reducer<DialogState> = (state, action) => {
    if (isActionType(action, OpenDialog)) {
        return { isOpen: true };
    }

    if (isActionType(action, CloseDialog)) {
        return { isOpen: false };
    }
    
    // For unrecognized actions (or in cases where actions have no effect), must return the existing state
    //  (or default initial state if none was supplied)
    return state || { isOpen: false };
};
開發者ID:skillsacademy,項目名稱:SkillsAcademy-Dev,代碼行數:13,代碼來源:DialogPage.ts

示例5: if

export const reducer: Reducer<AddPollState> = (state, action) => {
  
  if (isActionType(action, AddPoll)) {
    return { success: null, isLoading: true, pollId: state.pollId };
  } else if (isActionType(action, AddPollSuccess)) {
    return { success: true, isLoading: false, pollId: action.details.id };
  } else if (isActionType(action, AddPollFailure)) {
    return { success: false, isLoading: false, pollId: 0 };
  }
  
  // For unrecognized actions (or in cases where actions have no effect), must return the existing state
  // (or default initial state if none was supplied)
  return state || unloadedState;
};
開發者ID:dmayala,項目名稱:BallotboxCore,代碼行數:14,代碼來源:AddPoll.ts

示例6: if

export const reducer: Reducer<WeatherForecastsState> = (state, action) => {
    if (isActionType(action, RequestWeatherForecasts)) {
        return { startDateIndex: action.startDateIndex, isLoading: true, forecasts: state.forecasts };
    } else if (isActionType(action, ReceiveWeatherForecasts)) {
        // Only accept the incoming data if it matches the most recent request. This ensures we correctly
        // handle out-of-order responses.
        if (action.startDateIndex === state.startDateIndex) {
            return { startDateIndex: action.startDateIndex, forecasts: action.forecasts, isLoading: false };
        }
    }
    
    // For unrecognized actions (or in cases where actions have no effect), must return the existing state
    // (or default initial state if none was supplied)
    return state || unloadedState;
};
開發者ID:An0564,項目名稱:JavaScriptServices,代碼行數:15,代碼來源:WeatherForecasts.ts

示例7:

export const reducer: Reducer<GenresListState> = (state, action) => {
    if (isActionType(action, ReceiveGenresList)) {
        return { genres: action.genres, isLoaded: true };
    } else {
        return state || { genres: [], isLoaded: false };
    }
};
開發者ID:Naveen-Bhat,項目名稱:NodeServices,代碼行數:7,代碼來源:GenreList.ts

示例8:

export const reducer: Reducer<FeaturedAlbumsState> = (state, action) => {
    if (isActionType(action, ReceiveFeaturedAlbums)) {
        return { albums: action.albums, isLoaded: true };
    } else {
        return state || { albums: [], isLoaded: false };
    }
};
開發者ID:An0564,項目名稱:JavaScriptServices,代碼行數:7,代碼來源:FeaturedAlbums.ts

示例9:

export const reducer: Reducer<LocationState> = (state, action) => {
    if (isActionType(action, RequestLocation)) {
        return { name: action.location };
    } 

    return state || { name: "" };
};
開發者ID:mikeyjones,項目名稱:WeatherTest,代碼行數:7,代碼來源:Location.ts

示例10:

export const reducer: Reducer<CounterState> = (state, action) => {
    if (isActionType(action, IncrementCount)) {
        return { count: state.count + 1 };
    }
    
    // For unrecognized actions (or in cases where actions have no effect), must return the existing state
    //  (or default initial state if none was supplied)
    return state || { count: 0 };
};
開發者ID:An0564,項目名稱:JavaScriptServices,代碼行數:9,代碼來源:Counter.ts


注:本文中的redux-typed.isActionType函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。