Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export function* watchNodes() {
while (true) { // eslint-disable-line no-constant-condition
const racedActions = yield race([
take(actionTypes.CR.Nodes.ADD)
]);
const contextPath = Object.keys(racedActions).map(k => racedActions[k]).filter(action => action !== undefined)
.map(action => action.payload.contextPath)[0];
const state = yield select();
const node = getNode(contextPath)(state);
const observers = getObservers('nodes.byContextPath', contextPath);
try {
observers.forEach(observer => observer(node));
} catch (err) {
console.error(err);
yield put(actions.UI.FlashMessages.add('@neos/neos-ui/ui/plugin/observer/watchNodes',
err.message, 'error', 5000));
}
}
export default function* operation() {
yield takeLatest(Types.FETCH_MAP.START, initFetch);
// yield takeLatest(StationsTypes.FETCH_LIST.FAILURE, stationDataFailure);
yield race({
stationsSuccess: takeLatest(StationsTypes.FETCH_LIST.SUCCESS, dataFetched),
lastAvailabilities: takeLatest(LastAvailabilitiesTypes.FETCH_LIST.SUCCESS, dataFetched),
});
}
// only when we are sure that we have moved data inside of wallet
// we will go ahead and get a backup of wallet
const prepareBackupStatus: PrepareBackupStatus = yield select(
getPrepareBackupStatus
)
if (prepareBackupStatus !== PREPARE_BACKUP_SUCCESS) {
// prepare backup can only be in 3 states, loading, success, failure
// if it is not success, then we check for failure
if (prepareBackupStatus === PREPARE_BACKUP_FAILURE) {
throw new Error('Failed to write data back to wallet')
}
// if status is neither success nor failure, then we wait for it to success
// we will wait for 2 minutes for data to go into wallet
// and then we will timeout
const { prepareBackupSuccess, timeout } = yield race({
prepareBackupSuccess: take(PREPARE_BACKUP_SUCCESS),
timeout: call(delay, 120000),
})
if (timeout) {
throw new Error('Could not write data back to wallet in 2 minutes')
}
}
// call VCX method to encrypt wallet. Given path to store it, file name, & key to encrypt it
yield call(encryptWallet, {
encryptedFileLocation,
recoveryPassphrase,
})
// create zip file of zip up directory contents to be used as backup
const backupZipFile = yield call(zip, zipupDirectory, destinationZipPath)
export function* refreshQuery(state: ManagedQuerySagaState) {
const queryTask = yield fork(runQuery, state);
while (queryTask.isRunning()) {
// While the query is running, we still need to increment or
// decrement the auto-refresh count.
yield race({
finished: join(queryTask),
nextAction: call(processQueryManagementAction, state),
});
}
state.shouldRefreshQuery = false;
}
yield takeLatest(AUTOCOMPLETE_STARTED, function* fetchOrCancel(...args) {
yield race({
fetch: call(fetchAutocompleteResults, ...args),
cancel: take(AUTOCOMPLETE_CANCELLED),
});
});
}
export function* watchForResizing(options) {
let remainingIdAry= options.plotIdAry.slice(0);
let waitingForMore= true;
if (!visRoot().wcsMatchType) return;
while (waitingForMore) {
const raceWinner = yield race({
action: take([ImagePlotCntlr.UPDATE_VIEW_SIZE]),
timer: call(delay, 1000)
});
const {action}= raceWinner;
if (action && action.payload.plotId) {
remainingIdAry= remainingIdAry.filter( (id) => id!==action.payload.plotId);
waitingForMore= remainingIdAry.length>0;
}
else {
waitingForMore= false;
console.log('watchForResizing: hit timeout');
}
}
const vr= visRoot();
const pv= getPlotViewById(vr, vr.mpwWcsPrimId);
function* getArticles() {
try {
const guid = yield getGuid()
const {responseData, } = yield race({
responseData: call(getTrendingArticles, guid, TRENDING_ARTICLE_COUNT),
timeout: call(delay, 30000)
})
if(!responseData[0].response) return yield sendError(10000)
const recList = buildArticleList(responseData[0].response.list)
return yield sendSuccess(recList)
} catch (error){
return yield sendError(10000)
}
}
export function *listenGasOracle() {
const credentials = yield select(getCredentials);
const socket = api.websocketGasOracle(credentials);
const channel = yield call(createChannel, socket);
while (true) {
const { cancel, gasOracleStats } = yield race({
gasOracleStats: take(channel),
cancel: take(actions.STOP_GAS_ORACLE)
});
if (cancel) {
channel.close();
return;
}
yield put(actions.gasOracle.success(gasOracleStats));
}
}