本文整理匯總了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;
};