Dive into secure and efficient coding practices with our curated list of the top 10 examples showcasing 'electron-redux' in functional components in JavaScript. Our advanced machine learning engine meticulously scans each line of code, cross-referencing millions of open source libraries to ensure your implementation is not just functional, but also robust and secure. Elevate your React applications to new heights by mastering the art of handling side effects, API calls, and asynchronous operations with confidence and precision.
type: 'RESET_RESULT'
});
export const setFilter = (payload) => (dispatch) => {
// Temp fixxzzz
if (payload.page === 1) {
dispatch(resetResult());
}
dispatch({
type: SET_FILTER,
payload
});
dispatch(fetchMovies());
};
export const fetchMovies = createAliasedAction(
FETCH_MOVIES_REQUEST,
() => ({
types: [FETCH_MOVIES_REQUEST, FETCH_MOVIES_SUCCESS, FETCH_MOVIES_FAILURE],
// shouldRequest: state => !state.catalog.entities,
request: ({ catalog }) => getMovies(catalog.filter),
parser: ({ data }) => movieNormalizer(data)
})
);
export const fetchMovie = createAliasedAction(
FETCH_MOVIE,
(id) => ({
type: FETCH_MOVIE,
payload: getMovie(id),
})
);
type: SET_FILTER,
payload
});
dispatch(fetchMovies());
};
export const fetchMovies = createAliasedAction(
FETCH_MOVIES_REQUEST,
() => ({
types: [FETCH_MOVIES_REQUEST, FETCH_MOVIES_SUCCESS, FETCH_MOVIES_FAILURE],
// shouldRequest: state => !state.catalog.entities,
request: ({ catalog }) => getMovies(catalog.filter),
parser: ({ data }) => movieNormalizer(data)
})
);
export const fetchMovie = createAliasedAction(
FETCH_MOVIE,
(id) => ({
type: FETCH_MOVIE,
payload: getMovie(id),
})
);
import * as types from './types';
import { createAliasedAction } from 'electron-redux';
const updatePrices = createAliasedAction(types.PRICES_UPDATE, prices => ({
type: types.PRICES_UPDATE,
payload: prices
}));
export { updatePrices };
if (!rp.templates[templateId]) throw new Error('template does not exist');
const wallet = walletSelectors.getWallet(getState());
if (!wallet) return;
const attributes = marketplacesSelectors.selectKYCAttributes(
getState(),
wallet.id,
attributeIds
);
const application = await rp.session.createKYCApplication(rpName, templateId, attributes);
await dispatch(marketplacesActions.addKYCApplication(rpName, application));
};
export const marketplacesOperations = {
...marketplacesActions,
loadTransactions: createAliasedAction(
marketplacesTypes.MARKETPLACE_TRANSACTIONS_LOAD,
loadTransactionsOperation
),
loadStakes: createAliasedAction(marketplacesTypes.MARKETPLACE_STAKES_LOAD, loadStakesOperation),
placeStake: createAliasedAction(
marketplacesTypes.MARKETPLACE_STAKES_PLACE,
placeStakeOperation
),
withdrawStake: createAliasedAction(
marketplacesTypes.MARKETPLACE_STAKES_WITHDRAW,
withdrawStakeOperation
),
updateTransactionStatus: createAliasedAction(
marketplacesTypes.MARKETPLACE_TRANSACTIONS_UPDATE_STATUS,
updateTransactionStatusOperation
),
tx.gasPrice,
tx.gasLimit
)
);
await dispatch(marketplacesActions.showMarketplacePopupAction('pendingTransaction'));
await dispatch(marketplacesActions.clearCurrentTransactionAction());
};
export const cancelCurrentTransactionOperation = () => async (dispatch, getState) => {
await dispatch(marketplacesActions.clearCurrentTransactionAction());
await dispatch(marketplacesActions.showMarketplacePopupAction(null));
};
export const marketplacesOperations = {
...marketplacesActions,
loadTransactions: createAliasedAction(
marketplacesTypes.MARKETPLACE_TRANSACTIONS_LOAD,
loadTransactionsOperation
),
loadStakes: createAliasedAction(marketplacesTypes.MARKETPLACE_STAKES_LOAD, loadStakesOperation),
placeStake: createAliasedAction(
marketplacesTypes.MARKETPLACE_STAKES_PLACE,
placeStakeOperation
),
withdrawStake: createAliasedAction(
marketplacesTypes.MARKETPLACE_STAKES_WITHDRAW,
withdrawStakeOperation
),
updateTransactionStatus: createAliasedAction(
marketplacesTypes.MARKETPLACE_TRANSACTIONS_UPDATE_STATUS,
updateTransactionStatusOperation
),
import * as types from './types';
import { createAliasedAction } from 'electron-redux';
const updateWallet = createAliasedAction(types.WALLET_UPDATE, wallet => ({
type: types.WALLET_UPDATE,
payload: wallet
}));
const setAssociateError = error => ({
type: types.WALLET_ASSOCIATE_DID_ERROR_SET,
payload: error
});
const setDidOriginUrl = didOriginUrl => ({
type: types.WALLET_DID_ORIGIN_URL_SET,
payload: didOriginUrl
});
export { updateWallet, setAssociateError, setDidOriginUrl };
const txHistoryService = getGlobalContext().txHistoryService;
await dispatch(transactionHistoryActions.setProcessingAction(true));
await txHistoryService.reload(wallet);
await dispatch(transactionHistoryActions.setProcessingAction(false));
const transactions = await txHistoryService.getTransactions(wallet.address);
await dispatch(transactionHistoryActions.setTransactionsAction(transactions));
};
const operations = {
loadTransactions,
reloadTransactions
};
const transactionHistoryOperations = {
...transactionHistoryActions,
loadTransactionsOperation: createAliasedAction(
transactionHistoryTypes.TRANSACTION_HISTORY_LOAD_TRANSACTIONS,
operations.loadTransactions
),
reloadTransactionsOperation: createAliasedAction(
transactionHistoryTypes.TRANSACTION_HISTORY_RELOAD_TRANSACTIONS,
operations.reloadTransactions
)
};
const setTransactionsReducer = (state, action) => {
return { ...state, transactions: action.payload };
};
const setProcessingReducer = (state, action) => {
return { ...state, processing: action.payload };
};
import { normalize } from 'normalizr';
import { createAliasedAction } from 'electron-redux';
import MovieProvider from '../providers/MovieProvider';
import * as movieSchema from '../normalizers/movie';
export const FETCH_MOVIES_REQUEST = 'FETCH_MOVIES_REQUEST';
export const FETCH_MOVIES_SUCCESS = 'FETCH_MOVIES_SUCCESS';
export const FETCH_MOVIES_FAILURE = 'FETCH_MOVIES_FAILURE';
export const FETCH_MOVIE_REQUEST = 'FETCH_MOVIE_REQUEST';
export const FETCH_MOVIE_SUCCESS = 'FETCH_MOVIE_SUCCESS';
export const FETCH_MOVIE_FAILURE = 'FETCH_MOVIE_FAILURE';
export const fetchMovies = createAliasedAction(
FETCH_MOVIES_REQUEST,
() => ({
types: [FETCH_MOVIES_REQUEST, FETCH_MOVIES_SUCCESS, FETCH_MOVIES_FAILURE],
request: ({ catalog }) => MovieProvider.getMovies(catalog.filter),
parser: ({ data }) => normalize(data.results, movieSchema.movieList)
})
);
export const fetchMovie = createAliasedAction(
FETCH_MOVIE_REQUEST,
(id) => ({
types: [FETCH_MOVIE_REQUEST, FETCH_MOVIE_SUCCESS, FETCH_MOVIE_FAILURE],
request: () => MovieProvider.getMovie(id),
parser: ({ data }) => normalize(data, movieSchema.movie)
})
);
appTypes.APP_SET_TERMS_ACCEPTED,
operations.setTermsAccepted
),
networkStatusUpdateOperation: createAliasedAction(
appTypes.APP_SET_NETWORK_STATUS,
operations.networkStatusUpdateOperation
),
startAutoUpdateOperation: createAliasedAction(
appTypes.APP_START_AUTO_UPDATE,
operations.startAutoUpdate
),
downloadUpdateOperation: createAliasedAction(
appTypes.APP_DOWNLOAD_UPDATE,
operations.downloadUpdate
),
installUpdateOperation: createAliasedAction(
appTypes.APP_INSTALL_UPDATE,
operations.installUpdate
)
};
const setWalletsReducer = (state, action) => {
return { ...state, wallets: action.payload };
};
const setWalletsLoadingReducer = (state, action) => {
return { ...state, walletsLoading: action.payload };
};
const setHardwareWalletsReducer = (state, action) => {
return { ...state, hardwareWallets: action.payload };
};
const loadTokens = () => async (dispatch, getState) => {
const tokenService = getGlobalContext().tokenService;
const tokens = await tokenService.loadTokens();
dispatch(actions.setTokens(tokens));
};
const addToken = contractAddress => async dispatch => {
const tokenService = getGlobalContext().tokenService;
const tokenInfo = await tokenService.getTokenInfo(contractAddress);
await tokenService.addToken(tokenInfo);
dispatch(loadTokens());
};
export default {
...actions,
loadTokensOperation: createAliasedAction(types.TOKENS_LOAD, loadTokens),
addTokenOperation: createAliasedAction(types.TOKENS_ADD, addToken)
};