本文整理汇总了TypeScript中xstream.never函数的典型用法代码示例。如果您正苦于以下问题:TypeScript never函数的具体用法?TypeScript never怎么用?TypeScript never使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了never函数的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
});
示例2: app
function app(sources: TestSources) {
return {
other: concat(
sources.other.take(6).map(x => String(x)).startWith('a'),
xs.never(),
),
};
}
示例3: main
function main(sources: {whatever: StateSource<any>}) {
assert.strictEqual(!!sources.whatever, true);
assert.strictEqual(typeof sources.whatever, 'object');
assert.strictEqual(typeof sources.whatever.stream, 'object');
assert.strictEqual(typeof sources.whatever.select, 'function');
assert.strictEqual(typeof sources.whatever.isolateSource, 'function');
assert.strictEqual(typeof sources.whatever.isolateSink, 'function');
return {whatever: xs.never()};
}
示例4: app
function app(_sources: TestSources) {
return {
other: concat(
_sources.other
.take(6)
.map(String)
.startWith('a'),
xs.never()
),
};
}
示例5: driver
function driver(sink: Stream<number>): Stream<any> {
setTimeout(() => {
sink.subscribe({
next(x) {
assert.strictEqual(x, expected.shift());
},
error() {},
complete() {},
});
});
return xs.never();
}
示例6: it
it('should not accept a selector to an unknown element as input', function(done) {
const sandbox = sinon.createSandbox();
sandbox.stub(console, 'error');
makeDOMDriver('#nonsenseIdToNothing')(xs.never());
setTimeout(() => {
sinon.assert.calledOnce(console.error as any);
sinon.assert.calledWithExactly(
console.error as any,
sinon.match({
message: 'Cannot render into unknown element `#nonsenseIdToNothing`',
})
);
sandbox.restore();
done();
}, 100);
});
示例7: it
it('should start emitting the current location', function(done) {
const history$ = makeServerHistoryDriver()(xs.never());
const sub = history$.subscribe({
next: (location: Location) => {
assert(location.pathname);
done();
},
error: err => {},
complete: () => {},
});
setTimeout(() => {
sub.unsubscribe();
});
});
示例8: child
function child(sources: any, num: number) {
const vdom$ = sources.HTTP
// .select('cat')
// .flatten()
.map((res: any) => res.body.name)
.map((name: string) => 'My name is ' + name);
const request$ =
num === 1
? xs.of({
category: 'cat',
url: 'http://jsonplaceholder.typicode.com/users/1',
})
: xs.never();
return {
HTTP: request$,
DOM: vdom$,
};
}
示例9: mainWithState
return function mainWithState(sources: Forbid<So, N>): Omit<Si, N> {
const reducerMimic$ = xs.create<Reducer<T>>();
const state$ = reducerMimic$
.fold((state, reducer) => reducer(state), void 0 as T | undefined)
.drop(1);
const innerSources: So = sources as any;
innerSources[name] = new StateSource<any>(state$, name);
const sinks = main(innerSources);
if (sinks[name]) {
const stream$ = concat(
xs.fromObservable<Reducer<T>>(sinks[name]),
xs.never()
);
stream$.subscribe({
next: i => schedule(() => reducerMimic$._n(i)),
error: err => schedule(() => reducerMimic$._e(err)),
complete: () => schedule(() => reducerMimic$._c()),
});
}
return sinks as any;
};