本文整理汇总了TypeScript中@cycle/rxjs-run.default函数的典型用法代码示例。如果您正苦于以下问题:TypeScript default函数的具体用法?TypeScript default怎么用?TypeScript default使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了default函数的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: makeTelegramDriver
test.skip('should answer callback query with basic driver', t => {
let basicDriver = makeTelegramDriver(ACCESS_TOKEN)
let main = ({ bot }: Sources) => ({
bot: $.from([
bot.events('message').map(reply({
text: 'Test message',
reply_markup: {
inline_keyboard: [
[{ text: '1', callback_data: 'one' }],
[{ text: '2', callback_data: 'two' }]
]
}
})),
bot.events('callback_query')
.map(x => answerCallbackQuery(
{ text: x.callback_query.data, show_alert: true },
x))
.do(() => {
bot.dispose()
t.end()
})
])
})
let { sources, run } = Cycle(main, { bot: basicDriver })
run()
sources.bot.responses
.take(1)
.subscribe(
console.log.bind(console),
onError(sources, t))
})
示例2: function
beforeBind: function (view: View & {bindingContext; controller: Controller}) {
if (view.controller !== null) {
const context = view.controller.viewModel as any
if (!context || typeof context.cycle !== 'function') return
const count = context._cycleCount = (context._cycleCount || 0) + 1
if (context._cycleCount > 1) {
logger.error('would run the cycle more then once!', count)
return
}
const preparedSources = context.cycleDrivers || {}
const { drivers, onBind, onUnbind, dispose } = makeBindingDrivers(context, diContainer) //observerLocator, strategyLocator, signaler
Object.assign(preparedSources, drivers)
onBind()
context._cycleOnUnbind = onUnbind
const {run, sources, sinks} = Cycle(context.cycle.bind(context), preparedSources)
const disposeFunction = run()
const _cycleDispose = () => {
dispose()
disposeFunction()
}
context._cycleDispose = _cycleDispose
}
},