當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript adapt.adapt函數代碼示例

本文整理匯總了TypeScript中@cycle/run/lib/adapt.adapt函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript adapt函數的具體用法?TypeScript adapt怎麽用?TypeScript adapt使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了adapt函數的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: constructor

 constructor(private _mockConfig: MockConfig) {
   if (_mockConfig.elements) {
     this._elements = _mockConfig.elements as FantasyObservable;
   } else {
     this._elements = adapt(xs.empty());
   }
 }
開發者ID:ntilwalli,項目名稱:cyclejs,代碼行數:7,代碼來源:mockDOMSource.ts

示例2: elements

 public elements(): MemoryStream<HTMLBodyElement> {
   const out: DevToolEnabledSource & MemoryStream<HTMLBodyElement> = adapt(
     xs.of(document.body),
   );
   out._isCycleSource = this._name;
   return out;
 }
開發者ID:joeldentici,項目名稱:cyclejs,代碼行數:7,代碼來源:BodyDOMSource.ts

示例3: start

    return function delayOperator<T>(inputStream: Stream<T>): Stream<T> {
      const stream = xs.fromObservable(inputStream);
      let delayListener: any = null;

      const producer = {
        start(listener: Listener<T>) {
          delayListener = makeDelayListener<T>(
            schedule,
            currentTime,
            delayTime,
            listener
          );

          stream.addListener(delayListener);
        },

        stop() {
          if (delayListener) {
            stream.removeListener(delayListener);
          }
        },
      };

      return adapt(xs.create<T>(producer));
    };
開發者ID:,項目名稱:,代碼行數:25,代碼來源:

示例4: events

  public events(eventType: string, options?: EventsFnOptions): any {
    const streamForEventType = this._mockConfig[eventType] as any;
    const out: DevToolEnabledSource & FantasyObservable = adapt(streamForEventType || xs.empty());

    out._isCycleSource = 'MockedDOM';

    return out;
  }
開發者ID:whitecolor,項目名稱:cyclejs,代碼行數:8,代碼來源:mockDOMSource.ts

示例5: element

 public element(): any {
   const output$: MemoryStream<Element> = this.elements()
     .filter((arr: Array<any>) => arr.length > 0)
     .map((arr: Array<any>) => arr[0])
     .remember();
   const out: DevToolEnabledSource & MemoryStream<Element> = adapt(output$);
   out._isCycleSource = 'MockedDOM';
   return out;
 }
開發者ID:cyclejs,項目名稱:cyclejs,代碼行數:9,代碼來源:mockDOMSource.ts

示例6: adapt

    animationFrames: () => {
      const s = timeSource.periodic(16);

      if ('pipe' in s) {
        // This hack brought to you by the need to import rxjs's operators
        // and my desire to not force a dependency on rxjs
        return adapt(xs.fromObservable<number>(s).map(frame));
      }

      return s.map(frame);
    },
開發者ID:,項目名稱:,代碼行數:11,代碼來源:

示例7: events

 public events(eventType: string, options: EventsFnOptions = {}): Stream<Event> {
   let stream: Stream<Event>;
   if (options && typeof options.useCapture === 'boolean') {
     stream = fromEvent(document, eventType, options.useCapture);
   } else {
     stream = fromEvent(document, eventType);
   }
   const out: DevToolEnabledSource & Stream<Event> = adapt(stream);
   out._isCycleSource = this._name;
   return out;
 }
開發者ID:whitecolor,項目名稱:cyclejs,代碼行數:11,代碼來源:DocumentDOMSource.ts

示例8: isolateSink

 public isolateSink(sink: any, scope: string): any {
   return adapt(
     xs.fromObservable<any>(sink).map((vnode: VNode) => {
       if (vnode.sel && vnode.sel.indexOf(SCOPE_PREFIX + scope) !== -1) {
         return vnode;
       } else {
         vnode.sel += `.${SCOPE_PREFIX}${scope}`;
         return vnode;
       }
     })
   );
 }
開發者ID:cyclejs,項目名稱:cyclejs,代碼行數:12,代碼來源:mockDOMSource.ts

示例9: softNormalizeRequestInput

function requestInputToResponse$(reqInput: RequestInput): ResponseMemoryStream {
  let response$ = createResponse$(reqInput).remember();
  const reqOptions = softNormalizeRequestInput(reqInput);
  if (!reqOptions.lazy) {
    response$.addListener({next: () => {}, error: () => {}, complete: () => {}});
  }
  response$ = adapt(response$);
  Object.defineProperty(response$, 'request', {
    value: reqOptions,
    writable: false,
  });
  return response$ as ResponseMemoryStream;
};
開發者ID:whitecolor,項目名稱:cyclejs,代碼行數:13,代碼來源:http-driver.ts


注:本文中的@cycle/run/lib/adapt.adapt函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。