當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。