本文整理匯總了TypeScript中rx.Observable類的典型用法代碼示例。如果您正苦於以下問題:TypeScript Observable類的具體用法?TypeScript Observable怎麽用?TypeScript Observable使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了Observable類的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: RadioGroupFactory
function RadioGroupFactory(sources: any, props$: Observable<RadioGroupProps>,
children: Array<RadioButton>): CycleDomComponent {
const childrenDOMs: any[] = [];
const childrenValues: Observable<any>[] = [];
//TODO: allow other kinds of children?
for (let childRadio of children) {
// TODO: maybe remove RadioButton interface if I can make value$ compile using CycleDomComponent
// interface
childrenValues.push(childRadio.value$);
childrenDOMs.push(childRadio.DOM);
}
const itemMouseClick$ = Observable.just('RadioFirst');
const vtree$ = props$.map( (props) => {
const $radioGroupSelectedValue = Observable.combineLatest(childrenValues, (...values) => {
return { itemMouseClick$ };
}).startWith(props.value)
.do(x => console.log('radioGroupSelectedValue ' + x));
const className = classNames('radioGroup', props.className);
return (
div( { props: { className }, attrs: { 'data-cycle-ui': 'radio-group' } },
childrenDOMs
)
);
});
return {
DOM: vtree$,
};
}
示例2:
let main = () => ({
bot: $.from([
$.just(sendChatAction(
{ chat_id: GROUP_ID, action: 'typing' },
{}))
])
})