当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript redux-saga.put函数代码示例

本文整理汇总了TypeScript中redux-saga.put函数的典型用法代码示例。如果您正苦于以下问题:TypeScript put函数的具体用法?TypeScript put怎么用?TypeScript put使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了put函数的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: game

  const game: Saga = function* game(getState) {

    const score1 = yield* playLevelOne(getState)
    yield put(showScore(score1))

    const score2 = yield* playLevelTwo(getState)
    yield put(showScore(score2))

    const score3 = yield* playLevelThree(getState)
    yield put(showScore(score3))

  }
开发者ID:AlfredMan,项目名称:DefinitelyTyped,代码行数:12,代码来源:redux-saga-tests.ts

示例2: bgSync

 function* bgSync() {
   try {
     while(true) {
       yield put({type: 'REQUEST_START'})
       const result = yield call(someApi)
       yield put({type: 'REQUEST_SUCCESS', result})
       yield call(delay, 5000)
     }
   } catch(error) {
     if(error instanceof SagaCancellationException)
       yield put({type: 'REQUEST_FAILURE', message: 'Sync cancelled!'})
   }
 }
开发者ID:AlfredMan,项目名称:DefinitelyTyped,代码行数:13,代码来源:redux-saga-tests.ts

示例3: fetchPostsWithTimeout

  const fetchPostsWithTimeout:Saga = function* fetchPostsWithTimeout() {
    while( yield take('FETCH_POSTS') ) {
      // starts a race between 2 effects
      const {posts, timeout} = yield race({
        posts   : call(fetchApi, '/posts'),
        timeout : call(delay, 1000)
      })

      if(posts)
        put( {type: 'RECEIVE_POSTS', posts} )
      else
        put( {type: 'TIMEOUT_ERROR'} )
    }
  }
开发者ID:AlfredMan,项目名称:DefinitelyTyped,代码行数:14,代码来源:redux-saga-tests.ts

示例4: incrementAsync

  const incrementAsync:Saga = function* incrementAsync() {

    while(true) {

      // wait for each INCREMENT_ASYNC action
      const nextAction = yield take('INCREMENT_ASYNC')

      // delay is a sample function
      // return a Promise that resolves after (ms) milliseconds
      yield delay(1000)

      // dispatch INCREMENT_COUNTER
      yield put( {type: 'INCREMENT_COUNTER'} )
    }

  }
开发者ID:AlfredMan,项目名称:DefinitelyTyped,代码行数:16,代码来源:redux-saga-tests.ts

示例5: fetchProducts

 function* fetchProducts() {
   yield put( {type: 'REQUEST_PRODUCTS'} )
   const products = yield call(fetchApi, '/products')
   yield put( {type: 'RECEIVE_PRODUCTS', products } )
 }
开发者ID:AlfredMan,项目名称:DefinitelyTyped,代码行数:5,代码来源:redux-saga-tests.ts

示例6: fetchPosts

 function* fetchPosts() {
   yield put( {type: 'REQUEST_POSTS'} )
   const posts = yield call(fetchApi, '/posts')
   yield put( {type: 'RECEIVE_POSTS', posts} )
 }
开发者ID:AlfredMan,项目名称:DefinitelyTyped,代码行数:5,代码来源:redux-saga-tests.ts


注:本文中的redux-saga.put函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。