當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。