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


TypeScript effects.apply函數代碼示例

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


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

示例1: bgSync

 function* bgSync() {
   try {
     while(true) {
       yield put({type: 'REQUEST_START'})
       const result = yield apply(this, someApi)
       yield put({type: 'REQUEST_SUCCESS', result})
       yield call(delay, 5000)
     }
   } catch(error) {
     if(error instanceof SagaCancellationException && isCancelError(error))
       yield put({type: 'REQUEST_FAILURE', message: 'Sync cancelled!'})
   }
 }
開發者ID:HawkHouseIntegration,項目名稱:DefinitelyTyped,代碼行數:13,代碼來源:redux-saga-tests.ts

示例2: testApply

function* testApply(): SagaIterator {
  const obj = {
    foo: 'bar',
    getFoo() {
      return this.foo;
    },
    meth1(a: string) {
      return 1;
    },
    meth2(a: string, b: number) {
      return 1;
    },
    meth7(a: string, b: number, c: string, d: number, e: string, f: number, g: string) {
      return 1;
    },
  };

  // typings:expect-error
  yield apply(obj, obj.foo);
  yield apply(obj, obj.getFoo);
  yield apply<string>(obj, obj.getFoo);

  // typings:expect-error
  yield apply(obj, 'foo');
  yield apply(obj, 'getFoo');
  yield apply<typeof obj, 'getFoo', string>(obj, 'getFoo');

  // typings:expect-error
  yield apply(obj, obj.meth1);
  // typings:expect-error
  yield apply(obj, obj.meth1, []);
  // typings:expect-error
  yield apply(obj, obj.meth1, [1]);
  yield apply(obj, obj.meth1, ['a']);
  yield apply<number, string>(obj, obj.meth1, ['a']);

  // typings:expect-error
  yield apply(obj, 'meth1');
  // typings:expect-error
  yield apply(obj, 'meth1', []);
  // typings:expect-error
  yield apply(obj, 'meth1', [1]);
  yield apply(obj, 'meth1', ['a']);
  yield apply<typeof obj, 'meth1', number, string>(obj, 'meth1', ['a']);

  // typings:expect-error
  yield apply(obj, obj.meth2, ['a']);
  // typings:expect-error
  yield apply(obj, obj.meth2, ['a', 'b']);
  // typings:expect-error
  yield apply(obj, obj.meth2, [1, 'b']);
  yield apply(obj, obj.meth2, ['a', 1]);
  yield apply<number, string, number>(obj, obj.meth2, ['a', 1]);

  // typings:expect-error
  yield apply(obj, 'meth2', ['a']);
  // typings:expect-error
  yield apply(obj, 'meth2', ['a', 'b']);
  // typings:expect-error
  yield apply(obj, 'meth2', [1, 'b']);
  yield apply(obj, 'meth2', ['a', 1]);
  yield apply<typeof obj, 'meth2', number, string, number>(obj, 'meth2', ['a', 1]);

  // typings:expect-error
  yield apply(obj, obj.meth7, [1, 'b', 'c', 'd', 'e', 'f', 'g']);
  yield apply(obj, obj.meth7, ['a', 1, 'b', 2, 'c', 3, 'd']);
  yield apply<number, string, number, string, number, string, number>(
    obj, obj.meth7, ['a', 1, 'b', 2, 'c', 3, 'd'],
  );

  // typings:expect-error
  yield apply(obj, 'meth7', [1, 'b', 'c', 'd', 'e', 'f', 'g']);
  yield apply(obj, 'meth7', ['a', 1, 'b', 2, 'c', 3, 'd']);
  yield apply<typeof obj, 'meth7', number, string, number, string, number, string, number>(
    obj, 'meth7', ['a', 1, 'b', 2, 'c', 3, 'd'],
  );
}
開發者ID:javarouka,項目名稱:redux-saga,代碼行數:77,代碼來源:effects.ts

示例3: testApply

function* testApply(): SagaIterator {
  const obj = {
    foo: 'bar',
    getFoo() {
      return this.foo;
    },
    meth1(a: 'a') {},
    meth2(a: 'a', b: 'b') {},
    meth7(a: 'a', b: 'b', c: 'c', d: 'd', e: 'e', f: 'f', g: 'g') {},
  };

  // typings:expect-error
  yield apply(obj, obj.foo);
  yield apply(obj, obj.getFoo);

  // typings:expect-error
  yield apply(obj, 'foo');
  yield apply(obj, 'getFoo');

  // typings:expect-error
  yield apply(obj, obj.meth1);
  // typings:expect-error
  yield apply(obj, obj.meth1, []);
  // typings:expect-error
  yield apply(obj, obj.meth1, [1]);
  yield apply(obj, obj.meth1, ['a']);

  // typings:expect-error
  yield apply(obj, 'meth1', [1]);
  yield apply(obj, 'meth1', ['a']);

  // typings:expect-error
  yield apply(obj, obj.meth2, ['a'])
  // typings:expect-error
  yield apply(obj, obj.meth2, ['a', 1])
  // typings:expect-error
  yield apply(obj, obj.meth2, [1, 'b'])
  yield apply(obj, obj.meth2, ['a', 'b'])

  // typings:expect-error
  yield apply(obj, obj.meth7, [1, 'b', 'c', 'd', 'e', 'f', 'g']);
  yield apply(obj, obj.meth7, ['a', 'b', 'c', 'd', 'e', 'f', 'g']);
}
開發者ID:liesislukas,項目名稱:redux-saga,代碼行數:43,代碼來源:effects.ts

示例4: testApply

function* testApply(): SagaIterator {
  const obj = {
    foo: 'bar',
    getFoo() {
      return this.foo
    },
    meth1(a: string) {
      return 1
    },
    meth2(a: string, b: number) {
      return 1
    },
    meth7(a: string, b: number, c: string, d: number, e: string, f: number, g: string) {
      return 1
    },
  }

  // typings:expect-error
  yield apply(obj, obj.foo, [])
  yield apply(obj, obj.getFoo, [])
  yield apply<typeof obj, () => string>(obj, obj.getFoo, [])

  // typings:expect-error
  yield apply(obj, 'foo', [])
  yield apply(obj, 'getFoo', [])
  yield apply<typeof obj, 'getFoo'>(obj, 'getFoo', [])

  // typings:expect-error
  yield apply(obj, obj.meth1)
  // typings:expect-error
  yield apply(obj, obj.meth1, [])
  // typings:expect-error
  yield apply(obj, obj.meth1, [1])
  yield apply(obj, obj.meth1, ['a'])
  yield apply<typeof obj, (a: string) => number>(obj, obj.meth1, ['a'])

  // typings:expect-error
  yield apply(obj, 'meth1')
  // typings:expect-error
  yield apply(obj, 'meth1', [])
  // typings:expect-error
  yield apply(obj, 'meth1', [1])
  yield apply(obj, 'meth1', ['a'])
  yield apply<typeof obj, 'meth1'>(obj, 'meth1', ['a'])

  // typings:expect-error
  yield apply(obj, obj.meth2, ['a'])
  // typings:expect-error
  yield apply(obj, obj.meth2, ['a', 'b'])
  // typings:expect-error
  yield apply(obj, obj.meth2, [1, 'b'])
  yield apply(obj, obj.meth2, ['a', 1])
  yield apply<typeof obj, (a: string, b: number) => number>(obj, obj.meth2, ['a', 1])

  // typings:expect-error
  yield apply(obj, 'meth2', ['a'])
  // typings:expect-error
  yield apply(obj, 'meth2', ['a', 'b'])
  // typings:expect-error
  yield apply(obj, 'meth2', [1, 'b'])
  yield apply(obj, 'meth2', ['a', 1])
  yield apply<typeof obj, 'meth2'>(obj, 'meth2', ['a', 1])

  // typings:expect-error
  yield apply(obj, obj.meth7, [1, 'b', 'c', 'd', 'e', 'f', 'g'])
  yield apply(obj, obj.meth7, ['a', 1, 'b', 2, 'c', 3, 'd'])
  yield apply<typeof obj, (a: string, b: number, c: string, d: number, e: string, f: number, g: string) => number>(
    obj,
    obj.meth7,
    ['a', 1, 'b', 2, 'c', 3, 'd'],
  )

  // typings:expect-error
  yield apply(obj, 'meth7', [1, 'b', 'c', 'd', 'e', 'f', 'g'])
  yield apply(obj, 'meth7', ['a', 1, 'b', 2, 'c', 3, 'd'])
  yield apply<typeof obj, 'meth7'>(obj, 'meth7', ['a', 1, 'b', 2, 'c', 3, 'd'])
}
開發者ID:rahulrcopart,項目名稱:redux-saga,代碼行數:77,代碼來源:effects.ts


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