本文整理匯總了TypeScript中rxjs.range函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript range函數的具體用法?TypeScript range怎麽用?TypeScript range使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了range函數的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: range
observable1 = constructorZone1.run(() => {
return range(0, 3).pipe(
map(function(x: any) {
return range(x, 3);
}),
switchAll());
});
示例2: range
export const createEcho = (): Echo => {
const echoEffect = range(1, 5)
.pipe(
mergeMap(i => of(i).pipe(delay(500 * i))),
repeat(),
)
const { eventStream: mouseoutStream, next: mouseout } = ngEventHandler<void>()
const { eventStream: mouseoverStream, next: mouseover } = ngEventHandler<void>()
const def = of(0)
const effect = merge(
of(def),
mouseoverStream.pipe(
map(() => echoEffect.pipe(takeUntil(mouseoutStream)))),
mouseoutStream.pipe(map(() => def))
)
.pipe(mergeAll())
return {
mouseout,
mouseover,
effect$: effect,
}
}
示例3: Promise
await new Promise(resolve => {
range(0, trackDatas.length)
.pipe(
concatMap(index => {
return from(
new Promise(resolve2 => {
createTrack({
name: trackDatas[index].name,
desc: '',
creatorId: taskBoard.get('ownerId'),
boardId: taskBoardDomain.id
}).then(trackData => {
TaskCardModel
.where({
taskTrackId: trackDatas[index].id
})
.fetchAll().then(cards => {
const cardDatas = cards.map(c => {
return {
id: c.id,
title: c.get('title'),
type: c.get('type')
};
});
range(0, cardDatas.length)
.pipe(
concatMap(index2 => {
return from(
new Promise(resolve3 => {
createTaskCard({
title: cardDatas[index2].title,
boardId: taskBoard.id,
trackId: trackData.id,
type: cardDatas[index2].type || TaskCardType.NORMAL,
creatorId: taskBoard.get('ownerId')
}).then(() => {
resolve3();
});
})
);
})
)
.subscribe({
complete: () => {
resolve2();
}
});
});
});
})
);
})
)
.subscribe({
complete: () => {
resolve();
}
});
});
示例4: range
.fetchAll().then(cards => {
const cardDatas = cards.map(c => {
return {
id: c.id,
title: c.get('title'),
type: c.get('type')
};
});
range(0, cardDatas.length)
.pipe(
concatMap(index2 => {
return from(
new Promise(resolve3 => {
createTaskCard({
title: cardDatas[index2].title,
boardId: taskBoard.id,
trackId: trackData.id,
type: cardDatas[index2].type || TaskCardType.NORMAL,
creatorId: taskBoard.get('ownerId')
}).then(() => {
resolve3();
});
})
);
})
)
.subscribe({
complete: () => {
resolve2();
}
});
});
示例5: it
it('should count a range() source observable', (done: MochaDone) => {
range(1, 10).pipe(count()).subscribe(
(value: number) => {
expect(value).to.equal(10);
}, (x) => {
done(new Error('should not be called'));
}, () => {
done();
});
});
示例6: range
return errors => range(1, 10).pipe(
zip(errors, (i, err) => {
if (i == 10) {
throw err;
}
return i;
}),
flatMap(i => timer(i * 1000)),
)
示例7: it
it('should reduce with index with seed', (done: MochaDone) => {
const idx = [0, 1, 2, 3, 4, 5];
range(0, 6).pipe(reduce((acc, value, index) => {
expect(idx.shift()).to.equal(index);
return value;
}, -1)).subscribe(null, null, () => {
expect(idx).to.be.empty;
done();
});
});
示例8: it
it('should not work after has been disposed', function(done) {
const number$ = range(1, 3).pipe(concatMap(x => of(x).pipe(delay(150))));
function app(_sources: any): any {
return {other: number$};
}
const {sources, run: _run} = setup(app, {
other: (num$: any) => from(num$).pipe(map((num: any) => 'x' + num)),
});
let dispose: any;
sources.other.subscribe(function(x: any) {
assert.notStrictEqual(x, 'x3');
if (x === 'x2') {
dispose();
setTimeout(() => {
done();
}, 100);
}
});
dispose = _run();
});
示例9: map
map(function(x: any) {
return range(x, 3);
}),
示例10: range
import { range } from 'rxjs';
import { filter, map, reduce, tap } from 'rxjs/operators';
// observable
const range$ = range(1, 10);
// subscription
range$
.pipe(
map(item => item * 10),
filter(item => item % 20 === 0),
reduce((accumulator, item) => accumulator + item),
tap(sum => console.log(sum))
)
.subscribe();