當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript react-router-redux.routeActions類代碼示例

本文整理匯總了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')));
    }
  }
}
開發者ID:rosendi,項目名稱:figure,代碼行數:11,代碼來源:auth.ts

示例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);
    }
  }
}
開發者ID:rosendi,項目名稱:figure,代碼行數:27,代碼來源:submissions.ts

示例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));
  }
}
開發者ID:rosendi,項目名稱:figure,代碼行數:15,代碼來源:submissions.ts

示例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));
  }
}
開發者ID:rosendi,項目名稱:figure,代碼行數:15,代碼來源:forms.ts

示例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 });
    }
  }
}
開發者ID:rosendi,項目名稱:figure,代碼行數:21,代碼來源:forms.ts

示例6:

export const goBack = () => {
	return routeActions.goBack();
};
開發者ID:PhilipDavis,項目名稱:react-redux,代碼行數:3,代碼來源:GlobalActions.ts


注:本文中的react-router-redux.routeActions類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。