本文整理汇总了TypeScript中reselect.createSelector函数的典型用法代码示例。如果您正苦于以下问题:TypeScript createSelector函数的具体用法?TypeScript createSelector怎么用?TypeScript createSelector使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了createSelector函数的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: globalizeSelectors
*/
const selectRemote = (state: State) => state.remote;
export const logEntriesSelectors = globalizeSelectors(selectRemote, remoteLogEntriesSelectors);
export const logSummarySelectors = globalizeSelectors(selectRemote, remoteLogSummarySelectors);
export const sourceSelectors = globalizeSelectors(selectRemote, remoteSourceSelectors);
/**
* shared selectors
*/
export const sharedSelectors = {
selectFirstVisibleLogEntry: createSelector(
logEntriesSelectors.selectEntries,
logPositionSelectors.selectFirstVisiblePosition,
(entries, firstVisiblePosition) =>
firstVisiblePosition ? getLogEntryAtTime(entries, firstVisiblePosition) : null
),
selectMiddleVisibleLogEntry: createSelector(
logEntriesSelectors.selectEntries,
logPositionSelectors.selectMiddleVisiblePosition,
(entries, middleVisiblePosition) =>
middleVisiblePosition ? getLogEntryAtTime(entries, middleVisiblePosition) : null
),
selectLastVisibleLogEntry: createSelector(
logEntriesSelectors.selectEntries,
logPositionSelectors.selectLastVisiblePosition,
(entries, lastVisiblePosition) =>
lastVisiblePosition ? getLogEntryAtTime(entries, lastVisiblePosition) : null
),
selectLogFilterQueryAsJson: createSelector(
开发者ID:salihkardan,项目名称:kibana,代码行数:32,代码来源:selectors.ts
示例2: createSelector
export const makeIsApplyDisabledSelector = (nodeTypesRegistry: NodeTypesRegistry, validatorRegistry: ValidatorRegistry) => createSelector(
[
isDirty,
makeValidationErrorsSelector(nodeTypesRegistry, validatorRegistry)
],
(
isDirty,
validationErrors
) => {
return !isDirty || (isDirty && validationErrors !== null);
}
);
开发者ID:grebaldi,项目名称:PackageFactory.Guevara,代码行数:12,代码来源:selectors.ts
示例3: createSelector
/* eslint import/prefer-default-export: 0 */
import { AppState } from 'AppState';
import { createSelector } from 'reselect';
import { filter } from 'lodash';
const device = (state: AppState) => state.device;
const devicesSelector = createSelector(
device,
d => d.devices
);
const layerSelector = createSelector(
device,
d => d.layer
);
export const filteredDevices = createSelector(
devicesSelector,
layerSelector,
(devices, layer) => filter(devices, d => d.layer === layer)
);
开发者ID:chaosdorf,项目名称:dorfmap,代码行数:20,代码来源:device.ts
示例4: asChildFunctionRenderer
);
export const WithStreamItems = asChildFunctionRenderer(withStreamItems, {
onInitialize: props => {
if (!props.isReloading && !props.isLoadingMore) {
props.reloadEntries();
}
},
});
const selectItems = createSelector(
logEntriesSelectors.selectEntries,
logEntriesSelectors.selectIsReloadingEntries,
logPositionSelectors.selectIsAutoReloading,
// searchResultsSelectors.selectSearchResultsById,
(logEntries, isReloading, isAutoReloading /* , searchResults */) =>
isReloading && !isAutoReloading
? []
: logEntries.map(logEntry =>
createLogEntryStreamItem(logEntry /* , searchResults[logEntry.gid] || null */)
)
);
const createLogEntryStreamItem = (logEntry: LogEntry, searchResult?: SearchResult) => ({
kind: 'logEntry' as 'logEntry',
logEntry: {
gid: logEntry.gid,
origin: {
id: logEntry.gid,
index: '',
type: '',
},
开发者ID:spalger,项目名称:kibana,代码行数:32,代码来源:with_stream_items.ts
示例5: createSelector
import {ApplicationState} from "../store/application-state";
import {MessageVM} from "./message.vm";
import {Message} from "../../../shared/model/message";
import * as _ from 'lodash';
import {Participant} from "../../../shared/model/participant";
import { createSelector } from 'reselect';
// createSelector will rerender the ui only if participants or messages have been changed and the outcome will be
// mapMessagesToMessagesVM, this a pure function implements memoization (results stored in the cache)
export const messagesSelector = createSelector(getParticipants, getMessagesForCurrentThread, mapMessagesToMessagesVM);
function getMessagesForCurrentThread(state: ApplicationState): Message[] {
const currentThread = state.storeData.threads[state.uiState.currentThreadId];
// if the messageIds array is empty map will return an empty array
return currentThread? currentThread.messageIds.map(messageId => state.storeData.messages[messageId]):
[];
}
function getParticipants(state: ApplicationState) {
return state.storeData.participants;
}
function mapMessagesToMessagesVM(participants: {[key: number]: Participant}, messages:Message[]){
return messages.map(message=> {
const participantName = participants[message.participantId].name;
return mapMessageToMessageVM(participantName, message)
});
}
开发者ID:MidoShahin,项目名称:Chat-App-using-ngrx-store,代码行数:31,代码来源:messagesSelector.ts
示例6: buildGraph
.value();
}
function buildGraph(rootId) {
var typeIds = [rootId];
var nodes = [];
var types = _.keyBy(schema.types, 'id');
for (var i = 0; i < typeIds.length; ++i) {
var id = typeIds[i];
if (typeIds.indexOf(id) < i)
continue;
var type = types[id];
nodes.push(type);
typeIds.push(...getEdgeTargets(type));
}
return {
rootId,
nodes: _.keyBy(nodes, 'id'),
};
}
}
export const getTypeGraphSelector = createSelector(
getSchemaSelector,
state => state.displayOptions.rootTypeId,
getTypeGraph
);
开发者ID:codeaudit,项目名称:graphql-voyager,代码行数:30,代码来源:type-graph.ts
示例7: createSelector
import { PathAnimationBlock } from 'app/model/timeline';
import { createDeepEqualSelector, getAppState } from 'app/store/selectors';
import * as _ from 'lodash';
import { createSelector } from 'reselect';
const getTimelineState = createSelector(getAppState, s => s.timeline);
export const getAnimation = createSelector(getTimelineState, t => t.animation);
export const isAnimationSelected = createSelector(getTimelineState, t => t.isAnimationSelected);
export const getSelectedBlockIds = createDeepEqualSelector(
getTimelineState,
t => t.selectedBlockIds,
);
export const getSingleSelectedBlockId = createSelector(
getSelectedBlockIds,
blockIds => (blockIds.size === 1 ? blockIds.values().next().value : undefined),
);
export const getSingleSelectedPathBlock = createSelector(
[getAnimation, getSingleSelectedBlockId],
(anim, blockId) => {
if (!blockId) {
return undefined;
}
return _.find(
anim.blocks,
b => b.id === blockId && b instanceof PathAnimationBlock,
) as PathAnimationBlock;
},
);
export const getSelectedBlockLayerIds = createDeepEqualSelector(
[getAnimation, getSelectedBlockIds],
(anim, blockIds) => {
开发者ID:arpitsaan,项目名称:ShapeShifter,代码行数:31,代码来源:selectors.ts
示例8: createSelector
import { BLACK, WHITE } from './consts'
import { State } from './reducer'
import { createSelector } from 'reselect'
const selectBoard = (state: State) => state.board
const selectPlayer = (state: State) => state.player
export const createScoreSelector = () =>
createSelector([selectBoard], board => {
var black = 0
var white = 0
board.forEach(row => {
row.forEach(col => {
if (col === BLACK) {
black += 1
} else if (col === WHITE) {
white += 1
}
})
})
return { black, white }
})
export const startedSelector = createSelector([selectPlayer], player => !!player)
开发者ID:DanSnow,项目名称:react-reversi,代码行数:25,代码来源:selector.ts
示例9: createSelector
// case StatActions.REMOVE_ALL_NETWORK_ERROR:
// case StatActions.REMOVE_ALL_NETWORK_SUCCESS:
// case StatActions.UPDATE_ERROR:
// case StatActions.UPDATE_NETWORK:
// case StatActions.UPDATE_NETWORK_ERROR:
// case StatActions.UPDATE_NETWORK_SUCCESS:
// case StatActions.SELECT_ERROR:
default:
return state;
}
}
export const getIds = (s: StatState) => s.ids;
export const getEntities = (s: StatState) => s.entities;
export const getSelectedId = (s: StatState) => s.selectedStatId;
export const getLastAdded = (s: StatState) => {
const lastElement = s.ids.length - 1;
return s.entities[s.ids[lastElement]];
};
export const getStat = createSelector(getSelectedId, getEntities, (id, stats) => stats[id]);
export const getStats = createSelector(getIds, getEntities, (ids, entities) => {
return ids.map(id => entities[id]);
});
export const getMeta = createSelector(getIds, getSelectedId, (ids, selectedId) => {
return {ids, selectedId};
});
export const getAddedMeta = createSelector(getLastAdded, getMeta, (stat, meta) => {
return {stat, meta};
});
开发者ID:Margorah,项目名称:CharSheetNg2,代码行数:30,代码来源:stat-reducer.ts
注:本文中的reselect.createSelector函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论