• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript store.compose函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了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;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript store.createFeatureSelector函数代码示例发布时间:2022-05-28
下一篇:
TypeScript store.combineReducers函数代码示例发布时间:2022-05-28
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap