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


TypeScript EntityAdapter.getInitialState方法代碼示例

本文整理匯總了TypeScript中@ngrx/entity.EntityAdapter.getInitialState方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript EntityAdapter.getInitialState方法的具體用法?TypeScript EntityAdapter.getInitialState怎麽用?TypeScript EntityAdapter.getInitialState使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在@ngrx/entity.EntityAdapter的用法示例。


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

示例1: reducer

export interface FolderState extends EntityState<Folder> {
  foldersLoaded: boolean;
  foldersLoading: boolean;
  folderDetails: any;
  folderDetailsLoaded: boolean;
  folderDetailsLoading: boolean;
  selectedFolder: Folder;
}

export const adapter: EntityAdapter<Folder> = createEntityAdapter<Folder>();

export const initialState: FolderState = adapter.getInitialState({
  foldersLoaded: false,
  foldersLoading: false,
  folderDetails: null,
  folderDetailsLoaded: false,
  folderDetailsLoading: false,
  selectedFolder: { name: '', id: '', videosCount: 0}
});

export function reducer(
  state = initialState,
  action: FolderActions
): FolderState {
  switch (action.type) {
    case FolderActionTypes.LoadFolders: {
      return {
        ...state,
        foldersLoading: true
      };
    }
開發者ID:ArmyMusicOnline,項目名稱:ami,代碼行數:31,代碼來源:folder.reducer.ts

示例2: reducer

export interface State extends EntityState<Article> {
    selectedArticleId: string | null;
    selectedArticle: Article | null;
    page: Page | null;
}

export const adapter: EntityAdapter<Article> = createEntityAdapter<Article>({
    selectId: (article: Article) => article.id,
    sortComparer: false,
});

export const initialState: State = adapter.getInitialState({
    selectedArticleId: null,
    selectedArticle: null,
    page: {
        pageSize: 8,
        pageIndex: 0,
        startIndex: 0,
        endIndex: 0
    } as Page
});

export function reducer(
    state = initialState,
    action: ArticlesActions
): State {
    switch (action.type) {
        case ArticlesActionTypes.LoadArticle: {
            return {
                ...state,
                selectedArticleId: state.selectedArticleId,
                selectedArticle: null
開發者ID:evcraddock,項目名稱:erikvancraddock.com,代碼行數:32,代碼來源:articles.ts

示例3: reducer

import { HeroActions, HeroActionTypes } from '../actions/hero.actions';

export interface State extends EntityState<Hero> {
  loaded: boolean;
  loading: boolean;
  error: any;
  selectedHeroId: number;
  searchHeroes: Hero[];
}

export const adapter: EntityAdapter<Hero> = createEntityAdapter<Hero>();

export const initialState: State = adapter.getInitialState({
  loaded: false,
  loading: false,
  selectedHeroId: null,
  error: null,
  searchTerm: '',
  searchHeroes: null
});

export function reducer(state = initialState, action: HeroActions): State {
  switch (action.type) {
    case HeroActionTypes.heroGetHeroes:
    case HeroActionTypes.heroAddHero:
    case HeroActionTypes.heroDeleteHero:
    case HeroActionTypes.heroUpdateHero:
    case HeroActionTypes.heroSearchHeroes:
    case HeroActionTypes.heroGetHeroById:
      return {
        ...state,
        loading: true
開發者ID:klimentru1986,項目名稱:ngrx-toh,代碼行數:32,代碼來源:hero.reducer.ts

示例4: reducer

import { WidgetActions, WidgetActionTypes } from './widget.actions';
import { Widget } from './widget.model';

export interface State extends EntityState<Widget> {
  // additional entities state properties
  loaded: boolean;
  loading: boolean;
  selectedWidgetId: string;
}

export const adapter: EntityAdapter<Widget> = createEntityAdapter<Widget>();

export const initialState: State = adapter.getInitialState({
  // additional entity state properties
  loaded: false,
  loading: false,
  selectedWidgetId: '',
});

export function reducer(state = initialState, action: WidgetActions): State {
  switch (action.type) {
    case WidgetActionTypes.DATABASE_LISTEN_FOR_DATA_STOP: {
      return adapter.removeAll({
        ...state,
        loaded: false,
        loading: false,
        selectedWidgetId: '',
      });
    }

    case WidgetActionTypes.LOAD_SUCCESS: {
開發者ID:tja4472,項目名稱:ngrx-ionic-angularfire,代碼行數:31,代碼來源:widget.reducer.ts

示例5: reducer

import {createEntityAdapter, EntityAdapter, EntityState} from '@ngrx/entity';
import {createFeatureSelector, createSelector} from '@ngrx/store';
import {Content} from '../../api/model/content';
import * as contentActions from './content.actions';
import * as eventActions from '../event/event.actions';
import * as discussionActions from '../discussion/discussion.actions';
import {Discussion} from '../../api/model/discussion';

export const adapter: EntityAdapter<Content> = createEntityAdapter<Content>();

export interface State extends EntityState<Content> {
}

export const initialState: State = adapter.getInitialState({
});

export function reducer(state = initialState, action: contentActions.Union | eventActions.Union | discussionActions.Union): State {
  switch (action.type) {
    case contentActions.ActionTypes.CreateContentSuccess: {
      return adapter.addOne(action.content, state);
    }

    case contentActions.ActionTypes.AddManyContentItems: {
      return adapter.addMany(action.contents, state);
    }

    // TODO: move to own reducer
    case eventActions.ActionTypes.ParticipateSuccess: {
      return adapter.updateOne({id: action.event.contentId, changes: {event: action.event}}, state);
    }
開發者ID:arner,項目名稱:saevis,代碼行數:30,代碼來源:content.reducer.ts

示例6: lessonsReducer

  if (compare != 0) {
    return compare;
  }
  else {
    return l1.seqNo - l2.seqNo;
  }
}

export const adapter : EntityAdapter<Lesson> =
  createEntityAdapter<Lesson>({
      sortComparer: sortByCourseAndSeqNo
  });


const initialLessonsState = adapter.getInitialState({
  loading: false
});



export function lessonsReducer(state = initialLessonsState,
                               action: CourseActions): LessonsState {

  switch(action.type) {

    case CourseActionTypes.LessonsPageCancelled:

      return {
        ...state,
        loading:false
      };
開發者ID:mrplanktonlex,項目名稱:angular-ngrx-course,代碼行數:31,代碼來源:lessons.reducers.ts

示例7: reducer

export interface State extends EntityState<Role> {
  rolesLoaded: boolean;
  rolesLoading: boolean;
  availableMembers: RoleMember[];
  availableMembersLoaded: boolean;
}

export const adapter: EntityAdapter<Role> = createEntityAdapter<Role>({
  selectId: (role: Role) => role.name,
  sortComparer: false
});

export const initialState: State = adapter.getInitialState({
  rolesLoaded: false,
  rolesLoading: false,
  availableMembers: [],
  availableMembersLoaded: false
});

export function reducer(state = initialState, action: RoleActionsUnion): State {
  switch (action.type) {
    case RoleActionTypes.GetRoles: {
      return {
        ...state,
        rolesLoaded: false,
        rolesLoading: true
      };
    }

    case RoleActionTypes.GetRolesSuccess: {
      return adapter.addAll(action.payload, {
開發者ID:ArmyMusicOnline,項目名稱:ami,代碼行數:31,代碼來源:roles.reducer.ts

示例8: reducer

import { Organization } from '../../shared/models';

export interface OrganizationState extends EntityState<Organization> {
  entities: { [id: number]: Organization };
  organizationsLoading: boolean;
  organizationsLoaded: boolean;
}

export const adapter: EntityAdapter<Organization> = createEntityAdapter<
  Organization
>();

export const initialState: OrganizationState = adapter.getInitialState({
  entities: {},
  organizationsLoading: false,
  organizationsLoaded: false
});

export function reducer(
  state = initialState,
  action: fromOrganizations.OrganizationActions
): OrganizationState {
  switch (action.type) {
    case fromOrganizations.OrganizationActionTypes.LoadOrganizations: {
      return {
        ...state,
        organizationsLoading: true
      };
    }
開發者ID:ArmyMusicOnline,項目名稱:ami,代碼行數:29,代碼來源:organization.reducer.ts

示例9: reducer

  customFields: CustomField[];
  customFieldsLoaded: boolean;
  customFieldsLoading: boolean;
}

export const adapter: EntityAdapter<VideoListItem> = createEntityAdapter<
  VideoListItem
>();

export const initialState: VideoState = adapter.getInitialState({
  selectedVideos: [],
  videoDetails: null,
  videosLoaded: false,
  videosLoading: false,
  videoDetailsLoaded: false,
  videoDetailsLoading: false,
  currentFolder: null,
  currentPlaylist: null,
  customFields: [],
  customFieldsLoaded: false,
  customFieldsLoading: false
});

export function reducer(
  state = initialState,
  action: VideoActions
): VideoState {
  switch (action.type) {
    case VideoActionTypes.LoadVideos: {
      return {
        ...state,
開發者ID:ArmyMusicOnline,項目名稱:ami,代碼行數:31,代碼來源:video.reducer.ts

示例10: reducer

  sortedBy: string;
  categories: any[];
  selectedDocuments: number[];
}

export const adapter: EntityAdapter<CandidateListItem> = createEntityAdapter<
  CandidateListItem
>();

export const initialState: CandidateState = adapter.getInitialState({
  candidatesLoading: false,
  candidatesLoaded: false,
  candidateDetails: null,
  candidateDetailsLoading: false,
  candidateDetailsLoaded: false,
  orgList: [],
  orgFilter: -1,
  statusFilter: 'all',
  sortedBy: 'date',
  categories: [],
  selectedDocuments: []
});

export function reducer(
  state = initialState,
  action: fromCandidate.CandidateActions | fromBoard.BoardActions
): CandidateState {
  switch (action.type) {
    case fromBoard.BoardActionTypes.LoadBoard: {
      return {
        ...state,
開發者ID:ArmyMusicOnline,項目名稱:ami,代碼行數:31,代碼來源:candidate.reducers.ts

示例11: coursesReducer




export interface CoursesState extends EntityState<Course> {

  allCoursesLoaded:boolean;

}


export const adapter : EntityAdapter<Course> =
  createEntityAdapter<Course>();


export const initialCoursesState: CoursesState = adapter.getInitialState({
  allCoursesLoaded: false
});


export function coursesReducer(state = initialCoursesState , action: CourseActions): CoursesState {

  switch(action.type) {

    case CourseActionTypes.CourseLoaded:

      return adapter.addOne(action.payload.course, state);

    case CourseActionTypes.AllCoursesLoaded:

      return adapter.addAll(action.payload.courses, {...state, allCoursesLoaded:true});
開發者ID:mrplanktonlex,項目名稱:angular-ngrx-course,代碼行數:27,代碼來源:course.reducers.ts

示例12: reducer

import { VideoActions, VideoActionTypes } from '../actions/video.actions';

export interface PlaylistState extends EntityState<Playlist> {
  playlistsLoaded: boolean;
  playlistsLoading: boolean;
  playlistDetails: PlaylistDetails;
  playlistDetailsLoaded: boolean;
  playlistDetailsLoading: boolean;
}

export const adapter: EntityAdapter<Playlist> = createEntityAdapter<Playlist>();

export const initialState: PlaylistState = adapter.getInitialState({
  playlistsLoaded: false,
  playlistsLoading: false,
  playlistDetails: null,
  playlistDetailsLoaded: false,
  playlistDetailsLoading: false
});

export function reducer(
  state = initialState,
  action: PlaylistsAction | VideoActions
): PlaylistState {
  switch (action.type) {
    case PlaylistActionTypes.LoadPlaylists: {
      return {
        ...state,
        playlistsLoading: true
      };
    }
開發者ID:ArmyMusicOnline,項目名稱:ami,代碼行數:31,代碼來源:playlist.reducer.ts

示例13: reducer

import { createEntityAdapter, EntityAdapter, EntityState } from '@ngrx/entity';

import { Panel } from '../models';
import { PanelActionsUnion, PanelActionTypes } from './panels.actions';

export interface State extends EntityState<Panel> {
  panelsLoading: boolean;
  panelMemberReport: any;
}

export const adapter: EntityAdapter<Panel> = createEntityAdapter<Panel>();

export const initialState: State = adapter.getInitialState({
  panelsLoading: false,
  panelMemberReport: null
});

export function reducer(
  state = initialState,
  action: PanelActionsUnion
): State {
  switch (action.type) {
    case PanelActionTypes.GetPanels: {
      return {
        ...state,
        panelsLoading: true
      };
    }

    case PanelActionTypes.PanelsReceived: {
      return adapter.addAll(action.payload, {
開發者ID:ArmyMusicOnline,項目名稱:ami,代碼行數:31,代碼來源:panels.reducer.ts

示例14: reducer

 * object takes a record id selector function and
 * a sortComparer option which is set to a compare
 * function if the records are to be sorted.
 */
export const adapter: EntityAdapter<Book> = createEntityAdapter<Book>({
  selectId: (book: Book) => book.id,
  sortComparer: false,
});

/**
 * getInitialState returns the default initial state
 * for the generated entity state. Initial state
 * additional properties can also be defined.
 */
export const initialState: State = adapter.getInitialState({
  selectedBookId: null,
});

export function reducer(
  state = initialState,
  action:
    | BooksApiActions.BooksApiActionsUnion
    | BookActions.BookActionsUnion
    | ViewBookPageActions.ViewBookPageActionsUnion
    | CollectionApiActions.CollectionApiActionsUnion
): State {
  switch (action.type) {
    case BooksApiActions.BooksApiActionTypes.SearchSuccess:
    case CollectionApiActions.CollectionApiActionTypes.LoadBooksSuccess: {
      /**
       * The addMany function provided by the created adapter
開發者ID:iproduct,項目名稱:course-angular,代碼行數:31,代碼來源:books.reducer.ts

示例15: reducer

//  entities: { [id: number]: PanelListItem };
  panelsLoaded: boolean;
  panelsLoading: boolean;
  panelDetails: PanelDetails;
  panelDetailsLoading: boolean;
  panelDetailsLoaded: boolean;
}

export const adapter: EntityAdapter<PanelListItem> = createEntityAdapter<
  PanelListItem
>();

export const initialState: PanelState = adapter.getInitialState({
  //entities: {},
  panelsLoaded: false,
  panelsLoading: false,
  panelDetails: null,
  panelDetailsLoaded: false,
  panelDetailsLoading: false
});

export function reducer(
  state = initialState,
  action: PanelActions
): PanelState {
  switch (action.type) {
    case PanelActionTypes.LoadPanels: {
      return {
        ...state,
        panelsLoading: true
      };
    }
開發者ID:ArmyMusicOnline,項目名稱:ami,代碼行數:32,代碼來源:panel.reducer.ts


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