当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript adapt.setAdapt函数代码示例

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