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

TypeScript effects.apply函数代码示例

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

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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
TypeScript effects.call函数代码示例发布时间:2022-05-25
下一篇:
TypeScript effects.all函数代码示例发布时间: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