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

TypeScript adapt.setAdapt函数代码示例

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

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



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

示例1: it

  it('should allow listening to link clicks and change route', function(done) {
    setAdapt(x => x);
    const historyDriver = makeHistoryDriver();
    const sink = xs.never();
    const history$ = captureClicks(historyDriver)(sink);

    const sub = history$
      .compose(debounce(5))
      .drop(1)
      .subscribe({
        next: (location: Location) => {
          assert.strictEqual(location.pathname, '/test');
          sub.unsubscribe();
          sink.shamefullySendComplete();
          done();
        },
        error: err => {},
        complete: () => {},
      });

    const a = document.createElement('a');
    a.href = '/test';
    document.body.appendChild(a);

    setTimeout(() => {
      a.click();
    }, 10);
  });
开发者ID:ntilwalli,项目名称:cyclejs,代码行数:28,代码来源:common.ts


示例2: beforeEach

 beforeEach(function() {
   setAdapt(x => x);
 });
开发者ID:ntilwalli,项目名称:cyclejs,代码行数:3,代码来源:xstream.ts


示例3: keyof

import {
  setup as coreSetup,
  DisposeFunction,
  Driver,
  FantasyObservable,
  Sources,
  Sinks,
  CycleProgram,
} from '@cycle/run';

export type Drivers<So extends Sources, Si extends Sinks> = {
  [P in keyof (So & Si)]: Driver<FantasyObservable, any>
};

setAdapt(function adaptXstreamToRx(stream: Stream<any>): Observable<any> {
  return from(stream as any);
});

/**
 * Takes a `main` function and circularly connects it to the given collection
 * of driver functions.
 *
 * **Example:**
 * ```js
 * import run from '@cycle/rxjs-run';
 * const dispose = run(main, drivers);
 * // ...
 * dispose();
 * ```
 *
 * The `main` function expects a collection of "source" Observables (returned
开发者ID:ntilwalli,项目名称:cyclejs,代码行数:31,代码来源:index.ts


示例4: keyof

import {
  setup as coreSetup,
  DisposeFunction,
  Driver,
  FantasyObservable,
  Sources,
  Sinks,
  CycleProgram,
} from '@cycle/run';

export type Drivers<So extends Sources, Si extends Sinks> = {
  [P in keyof (So & Si)]: Driver<FantasyObservable, any>
};

setAdapt(function adaptXstreamToMost(stream: Stream<any>): MostStream<any> {
  return most.from(stream as any);
});

/**
 * Takes a `main` function and circularly connects it to the given collection
 * of driver functions.
 *
 * **Example:**
 * ```js
 * import run from '@cycle/most-run';
 * const dispose = run(main, drivers);
 * // ...
 * dispose();
 * ```
 *
 * The `main` function expects a collection of "source" streams (returned from
开发者ID:ntilwalli,项目名称:cyclejs,代码行数:31,代码来源:index.ts


示例5: setAdapt

// tslint:disable-next-line
import 'mocha';
import 'symbol-observable'; // tslint:disable-line
import * as assert from 'assert';
import {of, from, Observable} from 'rxjs';
import isolate from '../src/index';
import {setAdapt} from '@cycle/run/lib/adapt';

setAdapt(from as any);

describe('isolate', function() {
  beforeEach(function() {
    (isolate as any).reset();
  });

  it('should be a function', function() {
    assert.strictEqual(typeof isolate, 'function');
  });

  it('should throw if first argument is not a function', function() {
    assert.throws(() => {
      isolate('not a function' as any);
    }, /First argument given to isolate\(\) must be a 'dataflowComponent' function/i);
  });

  it('should throw if second argument is null', function() {
    function MyDataflowComponent() {}
    assert.throws(() => {
      isolate(MyDataflowComponent, null);
    }, /Second argument given to isolate\(\) must not be null/i);
  });
开发者ID:,项目名称:,代码行数:31,代码来源:


示例6: before

 before(() => setAdapt(stream => Observable.from(stream)));
开发者ID:joeldentici,项目名称:cyclejs,代码行数:1,代码来源:rxjs.ts


示例7: setAdapt

import * as most from 'most';
import {Stream} from 'most';
import {setAdapt} from '@cycle/run/lib/adapt';

import {mockTimeSource as mockTimeSourceUntyped} from './src/mock-time-source';
import {timeDriver as timeDriverUntyped} from './src/time-driver';
import {Frame} from './src/animation-frames';

setAdapt(stream => most.from(stream as any));

type Operator = <T>(stream: Stream<T>) => Stream<T>;

interface TimeSource {
  animationFrames(): Stream<Frame>;
  delay(delayTime: number): Operator;
  debounce(period: number): Operator;
  throttle(period: number): Operator;
  periodic(period: number): Stream<number>;
  throttleAnimation: Operator;
}

interface MockTimeSource extends TimeSource {
  diagram(str: string, values?: Object): Stream<any>;
  record(stream: Stream<any>): Stream<Array<any>>;
  assertEqual(actual: Stream<any>, expected: Stream<any>): void;
  run(cb?: (err?: Error) => void): void;
}

function mockTimeSource(args?: Object): MockTimeSource {
  return mockTimeSourceUntyped(args);
}
开发者ID:joeldentici,项目名称:cyclejs,代码行数:31,代码来源:most.ts


示例8: before

 before(() => setAdapt(library.adapt));
开发者ID:ntilwalli,项目名称:cyclejs,代码行数:1,代码来源:time.ts


示例9: before

 before(() => setAdapt(stream => most.from(stream as any)));
开发者ID:joeldentici,项目名称:cyclejs,代码行数:1,代码来源:most.ts


示例10: beforeEach

 beforeEach(function() {
   setAdapt(x => Observable.from(x as any));
   if (window.history) {
     window.history.replaceState(undefined, undefined, '/');
   }
 });
开发者ID:ntilwalli,项目名称:cyclejs,代码行数:6,代码来源:rxjs.ts



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
TypeScript rx-run.default函数代码示例发布时间:2022-05-28
下一篇:
TypeScript adapt.adapt函数代码示例发布时间:2022-05-28
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap