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


TypeScript store.compose函數代碼示例

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


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

示例1: it

    it(`should should compose functions`, () => {
      const addPrecision = compose(precision, addPtTwo);
      const addPrecisionCubed = compose(cube, addPrecision);

      expect(addPrecision(0.1)).toBe(0.3);
      expect(addPrecisionCubed(0.1)).toBe(0.027);
    });
開發者ID:rjokelai,項目名稱:platform,代碼行數:7,代碼來源:utils.spec.ts

示例2: addCase

export function formReducer<T extends FormState>(
    config: FormReducerOptions<T>
): ActionReducer<any, any> {
    const actionMap: ActionMap<T> = {};

    function addCase(
        types: string | string[] | undefined,
        func: ActionReducer<T, any>
    ) {
        if (types == null) {
            return;
        }
        if (Array.isArray(types)) {
            types.forEach(type => (actionMap[type] = func));
        } else {
            actionMap[types] = func;
        }
    }

    addCase(config.show, (state, action) => assign(state, { showForm: true }));
    addCase(config.hide, (state, action) => assign(state, { showForm: false }));
    addCase(config.toggle, (state, action) =>
        assign(state, { showForm: !state.showForm })
    );
    addCase(config.request, (state, action) =>
        assign(state, FormStates.Requesting)
    );
    addCase(config.success, (state, action) =>
        assign(state, FormStates.Success(config.successMessage))
    );
    addCase(config.failure, (state, action) =>
        assign(
            state,
            FormStates.Failure(
                getErrorMessage(action.payload, config.failureMessage)
            )
        )
    );

    if (config.extras) {
        config.extras.forEach(c => addCase(c.types, c.func));
    }

    const defaultState = config.defaultState
        ? config.defaultState
        : FormStates.Default;

    return compose(useDefaultState(defaultState), hashReducer)(actionMap);
}
開發者ID:mikule1,項目名稱:epool.eu,代碼行數:49,代碼來源:form.reducer.factory.ts

示例3: Effect

  Array.prototype.push.apply(meta, entries);
}

export function Effect({ dispatch } = { dispatch: true }): PropertyDecorator {
  return function(target: any, propertyName: string) {
    const metadata: EffectMetadata = { propertyName, dispatch };
    setEffectMetadataEntries(target, [metadata]);
  };
}

export function getSourceForInstance(instance: Object): any {
  return Object.getPrototypeOf(instance);
}

export const getSourceMetadata = compose(
  getEffectMetadataEntries,
  getSourceForInstance
);

export type EffectsMetadata<T> = {
  [key in keyof T]?:
    | undefined
    | {
        dispatch: boolean;
      }
};

export function getEffectsMetadata<T>(instance: T): EffectsMetadata<T> {
  const metadata: EffectsMetadata<T> = {};

  getSourceMetadata(instance).forEach(({ propertyName, dispatch }) => {
    metadata[propertyName] = { dispatch };
開發者ID:wgerven,項目名稱:platform,代碼行數:32,代碼來源:effects_metadata.ts

示例4: provideStore

import { provideStore, compose, combineReducers } from '@ngrx/store';
// reducers
import {videos} from './youtube-videos';
import {player} from './youtube-player';
import {nowPlaylist} from './now-playlist';
import {user} from './user-manager';
import { localStorageSync } from './ngrx-store-localstorage';

// Echoes State
let echoes = {
	videos: [],
	player: {}
};
export const store = provideStore(
	compose(
		localStorageSync(['videos', 'player', 'nowPlaylist'], true),
		combineReducers
	)({ videos, player, nowPlaylist, user })
);
開發者ID:bhanu009,項目名稱:echoes-ng2,代碼行數:19,代碼來源:store.ts

示例5: compose

import { Reducer, Action } from '@ngrx/store';
import { compose, combineReducers } from '@ngrx/store';
// reducers
import { videos, EchoesVideos } from './youtube-videos';
import { player, YoutubePlayerState} from './youtube-player';
import { nowPlaylist, YoutubeMediaPlaylist} from './now-playlist';
import { user, UserProfile } from './user-manager';
import { search, PlayerSearch} from './player-search';
import { localStorageSync } from './ngrx-store-localstorage';

/**
 * As mentioned, we treat each reducer like a table in a database. This means
 * our top level state interface is just a map of keys to inner state types.
 */
export interface EchoesState {
  videos: EchoesVideos;
  player: YoutubePlayerState;
  nowPlaylist: YoutubeMediaPlaylist;
  user: UserProfile;
  search: PlayerSearch;
}

export default compose(
  localStorageSync(['videos', 'player', 'nowPlaylist', 'search'], true),
  combineReducers
)({ videos, player, nowPlaylist, user, search });
開發者ID:Developer-Amit,項目名稱:echoes-ng2,代碼行數:26,代碼來源:index.ts

示例6: compose

import { compose, createFeatureSelector, createSelector } from '@ngrx/store';
import { IRccState } from './reducers';

export const rccState = createFeatureSelector<IRccState>('rcc');
export const getBackendsState = compose(s => s.backends, rccState);
export const getAppsState = compose(s => s.apps, rccState);
export const getPermissionsState = compose(s => s.permissions, rccState);
export const getDeveloperAccountsState = compose(s => s.developerAccounts, rccState);
export const getReviewNotesState = compose(s => s.reviewNotes, rccState);
export const getContactsState = compose(s => s.contacts, rccState);

export const getBackends = createSelector(getBackendsState, s => s.backends);
export const getBackendsStatus = createSelector(getBackendsState, s => s.backendsStatus);
export const getBackend = createSelector(getBackendsState, s => s.currentBackend);
export const getBackendStatus = createSelector(getBackendsState, s => s.getBackendStatus);
export const saveBackendStatus = createSelector(getBackendsState, s => s.saveBackendStatus);
export const getBackendRogerthatApps = createSelector(getBackendsState, s => s.apps);
export const getBackendAppAssets = createSelector(getBackendsState, s => s.appAssets);
export const getBackendAppAssetsStatus = createSelector(getBackendsState, s => s.appAssetsStatus);
export const getBackendAppAsset = createSelector(getBackendsState, s => s.appAsset);
export const getBackendAppAssetStatus = createSelector(getBackendsState, s => s.appAssetStatus);
export const getBackendAppAssetEditStatus = createSelector(getBackendsState, s => s.appAssetEditStatus);
export const getBackendBrandings = createSelector(getBackendsState, s => s.brandings);
export const getBackendBrandingsStatus = createSelector(getBackendsState, s => s.brandingsStatus);
export const getBackendBranding = createSelector(getBackendsState, s => s.branding);
export const getBackendBrandingEditStatus = createSelector(getBackendsState, s => s.brandingEditStatus);
export const getBackendPaymentProviders = createSelector(getBackendsState, s => s.paymentProviders);
export const getBackendPaymentProvidersStatus = createSelector(getBackendsState, s => s.paymentProvidersStatus);
export const getBackendPaymentProvider = createSelector(getBackendsState, s => s.paymentProvider);
export const getBackendPaymentProviderEditStatus = createSelector(getBackendsState, s => s.paymentProviderEditStatus);
export const getEmbeddedApps = createSelector(getBackendsState, s => s.embeddedApps);
開發者ID:our-city-app,項目名稱:plugin-mobicage-control-center,代碼行數:31,代碼來源:rcc.state.ts

示例7: compose

import { compose, createFeatureSelector, createSelector } from '@ngrx/store';
import { IIEState } from './reducers';

export const pluginSelector = createFeatureSelector<IIEState>('ie');
export const getScriptsState = compose(s => s.scripts, pluginSelector);

export const getScripts = createSelector(getScriptsState, s => s.scripts);
export const getScriptsStatus = createSelector(getScriptsState, s => s.scriptsStatus);
export const getScript = createSelector(getScriptsState, s => s.script);
export const getScriptStatus = createSelector(getScriptsState, s => s.scriptsStatus);
export const createScriptStatus = createSelector(getScriptsState, s => s.createScriptStatus);
export const updateScriptStatus = createSelector(getScriptsState, s => s.updateScriptStatus);
export const deleteScriptStatus = createSelector(getScriptsState, s => s.deleteScriptStatus);
export const scriptRun = createSelector(getScriptsState, s => s.scriptRun);
export const scriptRunStatus = createSelector(getScriptsState, s => s.scriptRunStatus);
開發者ID:our-city-app,項目名稱:plugin-interactive-explorer,代碼行數:15,代碼來源:interactive-explorer.state.ts


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