当前位置: 首页>>代码示例>>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;未经允许,请勿转载。