本文整理汇总了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());
}
}
示例2: elements
public elements(): MemoryStream<HTMLBodyElement> {
const out: DevToolEnabledSource & MemoryStream<HTMLBodyElement> = adapt(
xs.of(document.body),
);
out._isCycleSource = this._name;
return out;
}
示例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));
};
示例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;
}
示例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;
}
示例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);
},
示例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;
}
示例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;
}
})
);
}
示例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;
};