reselect#createSelector JavaScript Examples
The following examples show how to use
reselect#createSelector.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: index.js From Learning-Redux with MIT License | 6 votes |
visibleTodosSelector = createSelector(
todosSelector,
visibilityFilterSelector,
(todos, visibilityFilter) => {
switch (visibilityFilter) {
case 'SHOW_COMPLETED':
return todos.filter((t) => t.completed)
case 'SHOW_ACTIVE':
return todos.filter((t) => !t.completed)
case 'SHOW_ALL':
default:
return todos
}
}
)
Example #2
Source File: SearchSection.jsx From mapstore2-cadastrapp with GNU General Public License v3.0 | 6 votes |
OwnersList = connect(createSelector(
ownersListOpenSelector,
ownersListResultsSelector,
(show, owners) => ({
show,
owners
})
), {
onSearch: search,
onClose: () => clearOwners()
})(
// not rendering the modal at all when show is false is useful to reset internal state on every load
branch(({ show }) => !show, renderNothing)(OwnersModal)
)
Example #3
Source File: index.js From Learning-Redux with MIT License | 6 votes |
visibleTodosSelector = createSelector(
todosSelector,
visibilityFilterSelector,
(todos, visibilityFilter) => {
switch (visibilityFilter) {
case "SHOW_COMPLETED":
return todos.filter((t) => t.completed);
case "SHOW_ACTIVE":
return todos.filter((t) => !t.completed);
case "SHOW_ALL":
default:
return todos;
}
}
)
Example #4
Source File: LandedProperty.jsx From mapstore2-cadastrapp with GNU General Public License v3.0 | 6 votes |
mapLayersSelector = createSelector(
layersSelector,
additionalLayersSelector,
landedPropertyParcelleSelector,
getDefaultStyle,
getSelectedStyle,
(l1 = [], additionaLayers = [], parcelle, defaultStyle, selectedStyle) => ([
...l1,
// raster layer
...additionaLayers.filter(({ id }) => id === CADASTRAPP_RASTER_LAYER_ID).map(({options}) => options),
// vector layer to highlight the current parcelle
...(parcelle?.feature ? [{
id: 'vector-layer',
features: [{
...(parcelle?.feature ?? {}),
style: parcelle?.ufFeature ? selectedStyle : defaultStyle // if the ufFeature has been retrieved, so highlight it
}],
type: "vector",
name: "searchPoints",
visibility: true
}] : [])])
)
Example #5
Source File: selectors.js From snowbox with MIT License | 6 votes |
selectAll = (entity, hydrationLevels = 0) =>{
const hydrate = applyHydration(entity, hydrationLevels);
return createSelector(
selectEntities,
(allEntities) => (
hydrate(allEntities)(Object.values(allEntities[entity.key] || {}))
)
);
}
Example #6
Source File: reminder.js From jc-calendar with MIT License | 6 votes |
getFormattedReminder = createSelector(
[getReminder],
(reminder) => {
if (!reminder) return null;
return {
id: reminder.id,
description: reminder.description,
color: reminder.color,
city: reminder.city,
...millisToDateTimeStrings(reminder.dateTime),
};
}
)
Example #7
Source File: selectors.js From snowbox with MIT License | 6 votes |
selectOne = (entity, hydrationLevels = 0, idAttribute) => {
if (entity.singleton) {
return createSelector(
selectSingletons,
singletons => singletons[entity.key]
);
}
const hydrate = applyHydration(entity, hydrationLevels);
return createSelector(
selectEntities,
(state, props) => props[idAttribute || entity.idField],
(entities, id) => entities[entity.key] ?
hydrate(entities)(entities[entity.key][id]) :
null
);
}
Example #8
Source File: calendar.js From jc-calendar with MIT License | 6 votes |
getFormattedDateReminders = createSelector(
[getDateReminders, getReminders],
(dateReminders, reminders) => {
if (!dateReminders || !reminders) return [];
return dateReminders
.reduce((formatted, reminderId) => {
const reminder = reminders[reminderId];
return reminder
? [
...formatted,
{
...reminder,
displayTime: getDisplayTimeFromMillis(reminder.dateTime),
},
]
: formatted;
}, [])
.sort((a, b) => a.dateTime - b.dateTime);
}
)
Example #9
Source File: node-filters.js From ThreatMapper with Apache License 2.0 | 6 votes |
createCustomSelector = (formName) => {
if (!selectorCache[formName]) {
selectorCache[formName] = createSelector(
[
state => getFormValues(formName)(state),
],
selectorFunc
);
}
return selectorCache[formName];
}
Example #10
Source File: chat.js From haven with MIT License | 6 votes |
chatsListSelector = createSelector(
chatsSelector,
loadingSelector,
sentListSelector,
getBlockedNodes,
(chats, loading, sentList, blockedNodes) => {
const filteredList = sentList.filter(message => message.subject === '');
const offlinePeerIds = _.difference(
_.uniq(filteredList.map(message => message.peerID)),
chats.map(chat => chat.peerId),
);
const offlineChats = offlinePeerIds.map((peerId) => {
const messages = _.sortBy(
filteredList.filter(message => message.peerID === peerId),
message => moment(message.timestamp).valueOf(),
);
const lastMessage = messages[messages.length - 1];
const {
message, timestamp, loading, success,
} = lastMessage;
return {
lastMessage: message, peerId, timestamp, loading, success, outgoing: true, unread: false,
};
});
const newChats = _.sortBy(
[...chats, ...offlineChats],
chat => moment(chat.timestamp).valueOf(),
);
return {
data: newChats.filter(chat => !blockedNodes.includes(chat.peerId)),
loading,
};
},
)
Example #11
Source File: node-metric.js From ThreatMapper with Apache License 2.0 | 6 votes |
previousPinnedMetricTypeSelector = createSelector(
[
availableMetricTypesSelector,
state => state.get('pinnedMetricType'),
],
(metricTypes, pinnedMetricType) => {
const currentIndex = metricTypes.indexOf(pinnedMetricType);
const previousIndex = modulo(currentIndex - 1, metricTypes.count());
return metricTypes.get(pinnedMetricType ? previousIndex : 0);
}
)
Example #12
Source File: currency.js From haven with MIT License | 6 votes |
localLabelFromBCHSelector = createSelector(
ratesSelector,
localSymbolSelector,
convertorFromBCHSelector,
localDecimalPointsIfCryptoSelector,
(rates, localSymbol, convertCurrencyFromBCH, localDecimalPointsIfCrypto) => (price, coin = 'BTC') => {
if (isEmpty(rates)) {
return 'calculating...';
}
// if price is smaller than 0, it is between -1 and 0, so we make it 0
const localPrice = convertCurrencyFromBCH(price, coin);
// Currency-specific formatting
if (localDecimalPointsIfCrypto) {
return `${localSymbol}${removeZeros(localPrice.toFixed(localDecimalPointsIfCrypto))}`;
} else {
return `${localSymbol}${localPrice.toFixed(2).replace(/\d(?=(\d{3})+\.)/g, '$&,')}`;
}
},
)
Example #13
Source File: node-filters.js From ThreatMapper with Apache License 2.0 | 6 votes |
nodesLoadedSelector = createSelector(
[
state => state.get('nodesLoaded'),
loadedAllResourceLayersSelector,
isResourceViewModeSelector,
],
(nodesLoaded, loadedAllResourceLayers, isResourceViewMode) => (
// Since `nodesLoaded` is set when we receive nodes delta over websockets,
// it's a completely wrong criterion for determining if resource view is
// in the loading state - instead we look at the 'static' topologies whose
// nodes were loaded into 'nodesByTopology' and say resource view has been
// loaded if nodes for all the resource layer topologies have been loaded once.
isResourceViewMode ? loadedAllResourceLayers : nodesLoaded
)
)
Example #14
Source File: news.selectors.js From covid-19-monitor with MIT License | 5 votes |
selectNewsArticles = createSelector(
[selectArticles],
data => data.articles
)
Example #15
Source File: requests.js From website with MIT License | 5 votes |
createLoadingSelector = (actions, ...args) =>
createSelector(
globalState => globalState.requestsReducer,
getLoading(actions),
...args
)
Example #16
Source File: canvas.js From ThreatMapper with Apache License 2.0 | 5 votes |
windowHeightSelector = createSelector(
[
state => state.getIn(['viewport', 'height']),
],
() => window.innerHeight,
)
Example #17
Source File: selectors.js From hackchat-client with Do What The F*ck You Want To Public License | 5 votes |
makeSelectglobalNotifs = () =>
createSelector(
selectCommunicationProviderDomain,
(substate) => substate.globalNotifs,
)
Example #18
Source File: SearchSection.jsx From mapstore2-cadastrapp with GNU General Public License v3.0 | 5 votes |
mapSearchLoadingToProps = createSelector(
searchLoadingSelector,
(loading) => ({ loading })
)
Example #19
Source File: selectors.js From awsboilerplate with MIT License | 5 votes |
makeSelectJobResults = () => createSelector(selectHome, homeState => homeState.finished_jobs)
Example #20
Source File: month.js From jc-calendar with MIT License | 5 votes |
getDisplayMonthAndYear = createSelector([getMonth], (month) =>
month !== null ? getDisplayMonthAndYearHelper(month) : ''
)
Example #21
Source File: taxer.js From ReactCookbook-source with MIT License | 5 votes |
taxer = createSelector(
summarizer,
(summary) => summary.cost * 0.07
)
Example #22
Source File: topology.js From ThreatMapper with Apache License 2.0 | 5 votes |
isTableViewModeSelector = createSelector(
[state => state.get('topologyViewMode')],
viewMode => viewMode === TABLE_VIEW_MODE
)