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


TypeScript effects.put函數代碼示例

本文整理匯總了TypeScript中redux-saga/effects.put函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript put函數的具體用法?TypeScript put怎麽用?TypeScript put使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了put函數的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: getSearchResult

export function* getSearchResult({
  payload
}: ActionType<typeof bookmarkCreators.getSearchResult>): SagaIterator {
  try {
    if (!payload.searchKeyword) {
      yield put(bookmarkCreators.initBookmarkTrees())
      return
    }

    const {options}: RootState = yield select(R.identity)

    const searchResult: Array<BookmarkInfo> = yield call(searchBookmarks, {
      query: payload.searchKeyword
    })

    const isSearchTitleOnly = options[CST.OPTIONS.SEARCH_TARGET] === 1
    const sortedPartialResult = R.compose(
      sortByTitle,
      R.slice(0, options[CST.OPTIONS.MAX_RESULTS] || 0),
      (result: Array<BookmarkInfo>) => {
        const filteredResult = result.filter(R.propEq('type', CST.BOOKMARK_TYPES.BOOKMARK))
        if (isSearchTitleOnly) {
          return filteredResult.filter((bookmarkInfo: BookmarkInfo) => {
            return searchKeywordMatcher(payload.searchKeyword, bookmarkInfo.title)
          })
        }
        return filteredResult
      }
    )(searchResult)

    const searchResultTrees = [
      {
        children: sortedPartialResult,
        parent: simulateBookmark({
          id: CST.SEARCH_RESULT_ID,
          type: CST.BOOKMARK_TYPES.FOLDER
        })
      }
    ]
    yield put(bookmarkCreators.setBookmarkTrees(searchResultTrees))
  } catch (err) {
    console.error(err)
  }
}
開發者ID:foray1010,項目名稱:Popup-my-Bookmarks,代碼行數:44,代碼來源:getSearchResult.ts

示例2: authSaga

export function* authSaga(
    history: History,
    authApi: IAuthApi,
    usersApi: IUsersApi
) {
    let token: IToken = yield call(authApi.getAuthToken)

    if (token) {
        token = yield call(login, history, authApi, usersApi, { type: 'token', token })
    } else {
        yield put(actions.logoutSuccess())
    }

    yield put(actions.authCheckFinished(token && token.value || null))

    while (true) {
        if (!token) {
            const { payload: credentials } = yield take(actions.login.getType())
            token = yield call(login, history, authApi, usersApi, credentials)
            if (token) {
                history.push('/')
            }
        }

        if (!token) {
            continue
        }

        let userLoggedOut = false
        while (!userLoggedOut) {
            const { expired } = yield race({
                expired: delay(Math.max(token.exp - Date.now() - 30000, 0)),
                loggedOut: take(actions.logout.getType()),
            })

            if (expired) {
                token = yield call(login, history, authApi, usersApi, { type: 'token', token })
            } else {
                yield call(logout, authApi)
                userLoggedOut = true
            }
        }
    }
}
開發者ID:steam-react,項目名稱:steam,代碼行數:44,代碼來源:auth.ts

示例3: deletePostDeal

function* deletePostDeal(action: any): any {
	try {
		// 發送請求查詢
		const result = yield call(() => {
			return client.del('/api/posts/' + action.payload.id, {
				params: {},
			});
		});

		if (result.rt !== 1) {
			yield put({type: DEL_WIKI_SPECPOST_FAILED});
		} else {
			yield put({type: DEL_WIKI_SPECPOST_SUCCESS, payload: result.data});
		}

	} catch (e) {
		yield put({type: DEL_WIKI_SPECPOST_FAILED});
	}
}
開發者ID:weiweiwitch,項目名稱:third-lab,代碼行數:19,代碼來源:posts.ts

示例4: put

 return function* () {
     yield put(languagesActions.set([
         { id: 'english', caption: 'English' },
         { id: 'bulgarian', caption: 'Български (Bulgarian)' },
         { id: 'czech', caption: 'čeština (Czech)' },
         { id: 'russian', caption: 'Русский (Russian)' },
     ]))
     yield fork(authSaga, history, authApi, usersApi)
     yield fork(router, history, routeSettings)
 }
開發者ID:steam-react,項目名稱:steam,代碼行數:10,代碼來源:index.ts

示例5: onModelStatusChanged

export function* onModelStatusChanged({ modelData, teamspace, project, modelId, modelName }) {
	yield put(TeamspacesActions.setModelUploadStatus(teamspace, project, modelId, modelData));

	const currentUser = yield select(selectCurrentUser);
	if (modelData.user !== currentUser.username) {
		return;
	}

	if (modelData.status === uploadFileStatuses.ok) {
		yield put(SnackbarActions.show(`Model ${modelName} uploaded successfully`));
	}
	if (modelData.status === uploadFileStatuses.failed) {
		if (modelData.hasOwnProperty('errorReason') && modelData.errorReason.message) {
			yield put(SnackbarActions.show(`Failed to import ${modelName} model: ${modelData.errorReason.message}`));
		} else {
			yield put(SnackbarActions.show(`Failed to import ${modelName} model`));
		}
	}
}
開發者ID:3drepo,項目名稱:3drepo.io,代碼行數:19,代碼來源:model.sagas.ts

示例6: handleHelmetDuration

/** 在每個 TICK 的時候,更新坦克的 telmet 持續時間 */
function* handleHelmetDuration() {
  while (true) {
    const { delta }: actions.Tick = yield take(actions.A.Tick)
    const { tanks }: State = yield select()
    for (const tank of tanks.filter(t => t.alive && t.helmetDuration > 0).values()) {
      const nextDuration = Math.max(0, tank.helmetDuration - delta)
      yield put(actions.setHelmetDuration(tank.tankId, nextDuration))
    }
  }
}
開發者ID:socoolxin,項目名稱:battle-city,代碼行數:11,代碼來源:powerUpManager.ts

示例7: spawnHitActions

function* spawnHitActions({ tanks }: State, stat: Stat) {
  for (const [targetTankId, hitBullets] of stat.tankHitMap) {
    // 這裏假設一幀內最多隻有一發子彈同時擊中一架坦克
    const bullet = hitBullets[0]
    const sourceTankId = bullet.tankId
    const targetTank = tanks.get(targetTankId)
    const sourceTank = tanks.get(sourceTankId)
    yield put(actions.hit(bullet, targetTank, sourceTank))
  }
}
開發者ID:socoolxin,項目名稱:battle-city,代碼行數:10,代碼來源:bulletsSaga.ts

示例8: putFakeDirectory

function* putFakeDirectory() {
  const rootDirectory = xmlToTreeNode(`
    <directory name="components">
      <file name="main.pc">
      </file>
    </directory>
  `) as Directory;
  
  yield put(projectDirectoryLoaded(rootDirectory));
}
開發者ID:cryptobuks,項目名稱:tandem,代碼行數:10,代碼來源:project.ts

示例9: removeComment

export function* removeComment({ teamspace, modelId, issueData }) {
	try {
		const { issueNumber, commentIndex, _id, rev_id, guid } = issueData;
		const commentData = {
			comment: '',
			number: issueNumber,
			delete: true,
			commentIndex,
			_id,
			rev_id
		};

		yield API.updateIssue(teamspace, modelId, commentData);
		yield put(IssuesActions.deleteCommentSuccess(guid, issueData._id));
		yield put(SnackbarActions.show('Comment removed'));
	} catch (error) {
		yield put(DialogActions.showEndpointErrorDialog('remove', 'comment', error));
	}
}
開發者ID:3drepo,項目名稱:3drepo.io,代碼行數:19,代碼來源:issues.sagas.ts

示例10: deactivateMeasure

export function* deactivateMeasure() {
	try {
		yield all([
			Viewer.disableMeasure(),
			put(MeasureActions.setActiveSuccess(false))
		]);
	} catch (error) {
		DialogActions.showErrorDialog('deactivate', 'measure', error);
	}
}
開發者ID:3drepo,項目名稱:3drepo.io,代碼行數:10,代碼來源:measure.sagas.ts


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