• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript effects.put函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了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;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript effects.putResolve函数代码示例发布时间:2022-05-25
下一篇:
TypeScript effects.join函数代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap