本文整理匯總了TypeScript中react-router-redux.routeActions類的典型用法代碼示例。如果您正苦於以下問題:TypeScript routeActions類的具體用法?TypeScript routeActions怎麽用?TypeScript routeActions使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了routeActions類的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: redirectOnAuth
function* redirectOnAuth() {
while (true) {
const { signin, logout } = yield race({ signin: take(SIGNIN_SUCCESS), logout: take(LOGOUT_SUCCESS)});
if (signin) {
signin.performRedirect && (yield put(routeActions.push(yield call(refererPath, '/'))));
} else {
logout.performRedirect && (yield put(routeActions.push('/signin')));
}
}
}
示例2: watchDelete
function* watchDelete() {
while (true) {
const { id, formId } = yield take(DELETE_SUBMISSION);
const { auth: { api } } = yield select();
try {
const [{ payload: { prevRowId } }] = yield [
take(action => action.query === 'SUBMISSIONS' && action.type === ROW_REMOVED && action.payload.row.id === id),
api.deleteSubmission(id),
];
const { submissions } = yield select();
if (prevRowId) {
const nextRow = submissions.rows.get(submissions.rows.findIndex(row => row.id === prevRowId) + 1);
var redirectTo = nextRow ? nextRow.id : prevRowId;
} else {
var redirectTo = submissions.rows.isEmpty() ? '' : submissions.rows.first().id;
}
yield put(routeActions.push(`forms/${formId}/submissions/${redirectTo}`));
} catch(error) {
console.log(error);
}
}
}
示例3: indexRedirect
function* indexRedirect() {
while (true) {
yield take(REDIRECT_TO_FIRST_SUBMISSION);
const { submissions, params: { formId } } = yield select();
if (submissions.rows.isEmpty()) {
var redirectTo = `forms/${formId}/submissions`;
} else {
var redirectTo = `forms/${formId}/${submissions.rows.get(0).id}`;
}
yield put(routeActions.push(redirectTo));
}
}
示例4: watchIndexRedirect
function* watchIndexRedirect() {
while (true) {
yield take(REDIRECT_TO_FIRST_FORM);
const { forms } = yield select();
if (forms.rows.isEmpty()) {
var redirectTo = 'forms/new';
} else {
var redirectTo = `forms/${forms.rows.get(0).id}`;
}
yield put(routeActions.push(redirectTo));
}
}
示例5: watchCreate
function* watchCreate() {
while (true) {
const { payload, resolve, reject } = yield take(CREATE_FORM);
const { api } = yield select(state => state.auth);
try {
const { id } = yield api.createForm(payload);
const { forms } = yield select();
if (!forms.rows.some(form => form.id === id)) {
yield take(action => action.query === 'FORMS' && action.type === ROW_ADDED && action.payload.row.id === id);
}
resolve();
yield put(routeActions.push(`/forms/${id}`));
} catch(error) {
typeof error.message === 'object' ? reject(error.message) : reject({ _error: error.message });
}
}
}
示例6:
export const goBack = () => {
return routeActions.goBack();
};