How to use the @ngxs/store.createSelector function in @ngxs/store

To help you get started, we’ve selected a few @ngxs/store examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github abpframework / abp / npm / ng-packs / dist / core / fesm2015 / abp-ng.core.js View on Github external
static getDeep(keys) {
        if (typeof keys === 'string') {
            keys = keys.split('.');
        }
        if (!Array.isArray(keys)) {
            throw new Error('The argument must be a dot string or an string array.');
        }
        /** @type {?} */
        const selector = createSelector([ConfigState_1], (/**
         * @param {?} state
         * @return {?}
         */
        function (state) {
            return ((/** @type {?} */ (keys))).reduce((/**
             * @param {?} acc
             * @param {?} val
             * @return {?}
             */
            (acc, val) => {
                if (acc) {
                    return acc[val];
                }
                return undefined;
            }), state);
        }));
github abpframework / abp / npm / ng-packs / packages / core / src / lib / states / config.state.ts View on Github external
static getDeep(keys: string[] | string) {
    if (typeof keys === 'string') {
      keys = keys.split('.');
    }

    if (!Array.isArray(keys)) {
      throw new Error('The argument must be a dot string or an string array.');
    }

    const selector = createSelector(
      [ConfigState],
      (state: Config.State) => {
        return (keys as string[]).reduce((acc, val) => {
          if (acc) {
            return acc[val];
          }

          return undefined;
        }, state);
      },
    );

    return selector;
  }
github abpframework / abp / npm / ng-packs / dist / core / esm2015 / lib / states / config.state.js View on Github external
static getDeep(keys) {
        if (typeof keys === 'string') {
            keys = keys.split('.');
        }
        if (!Array.isArray(keys)) {
            throw new Error('The argument must be a dot string or an string array.');
        }
        /** @type {?} */
        const selector = createSelector([ConfigState_1], (/**
         * @param {?} state
         * @return {?}
         */
        (state) => {
            return ((/** @type {?} */ (keys))).reduce((/**
             * @param {?} acc
             * @param {?} val
             * @return {?}
             */
            (acc, val) => {
                if (acc) {
                    return acc[val];
                }
                return undefined;
            }), state);
        }));
github ovh / cds / ui / src / app / store / queue.state.ts View on Github external
static getCurrent() {
        return createSelector(
            [QueueState],
            (state: QueueStateModel): QueueStateModel => state
        );
    }
github abpframework / abp / npm / ng-packs / dist / core / fesm2015 / abp-ng.core.js View on Github external
static getApiUrl(key) {
        /** @type {?} */
        const selector = createSelector([ConfigState_1], (/**
         * @param {?} state
         * @return {?}
         */
        function (state) {
            return state.environment.apis[key || 'default'].url;
        }));
        return selector;
    }
    /**
github abpframework / abp / npm / ng-packs / packages / core / src / lib / states / config.state.ts View on Github external
static getGrantedPolicy(key: string) {
    const selector = createSelector(
      [ConfigState],
      (state: Config.State): boolean => {
        if (!key) return true;
        return snq(() => state.auth.grantedPolicies[key], false);
      },
    );

    return selector;
  }
github abpframework / abp / npm / ng-packs / dist / core / esm2015 / lib / states / config.state.js View on Github external
static getSettings(keyword) {
        /** @type {?} */
        const selector = createSelector([ConfigState_1], (/**
         * @param {?} state
         * @return {?}
         */
        (state) => {
            if (keyword) {
                /** @type {?} */
                const keys = snq((/**
                 * @return {?}
                 */
                () => Object.keys(state.setting.values).filter((/**
                 * @param {?} key
                 * @return {?}
                 */
                key => key.indexOf(keyword) > -1))), []);
                if (keys.length) {
                    return keys.reduce((/**
github abpframework / abp / npm / ng-packs / dist / core / esm2015 / lib / states / config.state.js View on Github external
static getApiUrl(key) {
        /** @type {?} */
        const selector = createSelector([ConfigState_1], (/**
         * @param {?} state
         * @return {?}
         */
        (state) => {
            return state.environment.apis[key || 'default'].url;
        }));
        return selector;
    }
    /**
github xmlking / ngx-starter-kit / libs / chat-box / src / lib / state / chat-box.store.ts View on Github external
static getConversationById(id: string) {
    return createSelector(
      [ChatBoxState],
      (state: ChatBoxStateModel) => {
        return state.conversations.find(con => con.id === id);
      },
    );
  }
github abpframework / abp / npm / ng-packs / dist / core / esm2015 / lib / states / config.state.js View on Github external
static getSetting(key) {
        /** @type {?} */
        const selector = createSelector([ConfigState_1], (/**
         * @param {?} state
         * @return {?}
         */
        (state) => {
            return snq((/**
             * @return {?}
             */
            () => state.setting.values[key]));
        }));
        return selector;
    }
    /**