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