本文整理汇总了TypeScript中@cycle/run.run函数的典型用法代码示例。如果您正苦于以下问题:TypeScript run函数的具体用法?TypeScript run怎么用?TypeScript run使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了run函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: it
it('should support selecting the body element', function(done) {
function app(sources: {DOM: MainDOMSource}) {
return {
DOM: xs.of(div('hello world')),
};
}
const {sinks, sources, run} = setup(app, {
DOM: makeDOMDriver(createRenderTarget()),
});
let dispose: any;
sources.DOM.select('body').events('click').take(1).addListener({
next: (event: Event) => {
assert.equal((event.target as HTMLElement).tagName, 'BODY');
setTimeout(() => {
dispose();
done();
});
},
});
dispose = run();
simulant.fire(document.body, 'click');
});
开发者ID:nlarche,项目名称:cyclejs,代码行数:24,代码来源:select.ts
示例2: div
transform: `translate(${link.position.x}px, ${link.position.y}px)`
}
}, [img({ attrs: { src: link.image }})]))
return div(vnodes)
}
function main({ time, DOM }) {
const raf$ = time.animationFrames()
const pause$ = DOM
.select("document")
.events("keyup")
.filter(event => event.keyCode == 32)
.fold(acc => !acc, false)
return {
DOM: raf$
.compose(sampleCombine(pause$))
.filter(([_, paused]) => !paused)
.fold(updateState, links)
.map(render)
}
}
run(main, {
DOM: makeDOMDriver("#main"),
time: timeDriver
});
开发者ID:atomrc,项目名称:find.thomasbelin.fr,代码行数:30,代码来源:application.ts
示例3: normalize
import { makeGithubDriver } from 'drivers/github';
normalize();
setupPage('#app');
cssRaw(`
#app {
font-family: medium-content-sans-serif-font,Lucida Grande,Lucida Sans Unicode,Lucida Sans,Geneva,Arial,sans-serif;
background: white;
color: #333;
display: flex;
}
.layout {
display: flex;
flex: 1;
flex-direction: column;
}
h1, h2, h3, h4, h5, h6 {
font-family: medium-ui-sans-serif-text-font,-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Oxygen,Ubuntu,Cantarell,"Open Sans","Helvetica Neue",sans-serif;
font-weight: 100;
}
`);
run(App, {
dom: makeDOMDriver('#app'),
history: captureClicks(makeHashHistoryDriver()),
github: makeGithubDriver()
});
开发者ID:cyclejs-community,项目名称:typescript-starter-cycle,代码行数:30,代码来源:app.ts
示例4: div
method: 'GET',
};
});
const user$ = sources.HTTP.select('users')
.flatten()
.map(res => res.body as UserData)
.startWith(null);
const vdom$ = user$.map(user =>
div('.users', [
button('.get-random', 'Get random user'),
user === null ? null : div('.user-details', [
h1('.user-name', user.name),
h4('.user-email', user.email),
a('.user-website', {attrs: {href: user.website}}, user.website),
]),
]),
);
return {
DOM: vdom$,
HTTP: getRandomUser$,
};
}
run(main, {
DOM: makeDOMDriver('#main-container'),
HTTP: makeHTTPDriver(),
});
开发者ID:joeldentici,项目名称:cyclejs,代码行数:30,代码来源:index.ts
示例5: run
import { App } from './components/App';
import { makeDOMDriver } from '@cycle/dom';
import { makeHashHistoryDriver } from '@cycle/history';
import { makeOperatorsDriver } from './drivers/operators';
import { run } from '@cycle/run';
run(App, {
dom: makeDOMDriver('#app'),
history: makeHashHistoryDriver(),
operators: makeOperatorsDriver()
});
开发者ID:artfuldev,项目名称:xstream-marbles,代码行数:11,代码来源:app.ts
示例6: normalize
appElement.style.cssText = 'height: 100%; text-align: center; padding-top: 50vh; background-color: black;'
appElement.id = 'nope'
}
normalize()
setupPage('#app')
const popArtShadow = {textShadow: '5px 5px 0 #000, 2px 0 0 black, 0 2px 0 black, 0 -2px 0 black, -2px 0 0 black', color: '#fff'}
cssRule('body', {fontFamily: '"PT Sans", sans-serif', background: `#bb270f url(${bgImage})`, backgroundSize: 'cover', color: '#fff', fontSize: '20px'})
cssRule('h1', {fontFamily: 'Bangers, sans-serif', transform: 'rotate(-4deg)', letterSpacing: '5px', margin: '150px 0 20px 0', textAlign: 'center', fontSize: '4em'}, popArtShadow)
cssRule('h2', {fontFamily: 'Bangers, sans-serif', transform: 'rotate(0deg)', letterSpacing: '2px', margin: '30px 0 20px 0', textAlign: 'center', fontSize: '2em'}, popArtShadow)
cssRule('a', {color: '#fff'})
const main : Component = onionify(App)
const drivers : any = {
DOM: makeDOMDriver('#app'),
HTTP: makeHTTPDriver()
}
export const driverNames : string[] = Object.keys(drivers)
// Cycle apps (main functions) are allowed to return any number of sinks streams
// This sets defaults for all drivers that are not used by the app
const defaultSinks : (s : Sources) => RootSinks = sources => ({
...driverNames.map(n => ({ [n]: xs.never() })).reduce(Object.assign, {}),
...main(sources)
})
run(defaultSinks, drivers)
开发者ID:klarna,项目名称:the-konferense,代码行数:30,代码来源:index.ts
示例7: onionify
import 'babel-polyfill' //This will be replaced based on your babel-env config
import { run } from '@cycle/run'
import { makeDOMDriver } from '@cycle/dom'
import onionify from 'cycle-onionify'
import { Component } from './interfaces'
import { App } from './app'
const main: Component = onionify(App)
const drivers: any = {
DOM: makeDOMDriver('#app'),
}
run(main, drivers)
开发者ID:michalvankodev,项目名称:portfolio,代码行数:16,代码来源:index.ts
示例8: wrapMain
import { setup, run } from '@cycle/run'
import { rerunner } from 'cycle-restart'
import isolate from '@cycle/isolate'
/// #if DEVELOPMENT
import { restartable } from 'cycle-restart'
/// #endif
import { buildDrivers, wrapMain } from './drivers'
import { Component } from './interfaces'
import { App } from './components/app'
const main: Component = wrapMain(App)
/// #if PRODUCTION
run(main as any, buildDrivers(([k, t]) => [k, t()]))
/// #else
const mkDrivers = () =>
buildDrivers(([k, t]) => {
if (k === 'DOM') {
return [k, restartable(t(), { pauseSinksWhileReplaying: false })]
}
if (k === 'time' || k === 'router') {
return [k, t()]
}
return [k, restartable(t())]
})
const rerun = rerunner(setup, mkDrivers, isolate)
rerun(main)
if (module.hot) {
开发者ID:OpenDirective,项目名称:brian,代码行数:31,代码来源:index.ts
示例9: div
.map(([fn, ln]) => `${ln.toUpperCase()}, ${fn}`);
const invalidName$ = rawFullName$
.filter(([fn, ln]) => fn.length === 0 || ln.length < 3)
.mapTo('');
const name$ = xs.merge(validName$, invalidName$);
const vdom$ = name$.map(name =>
div([
p([
'First name',
input('.first', { attrs: { type: 'text' } }),
]),
p([
'Last name',
input('.last', { attrs: { type: 'text' } }),
]),
h2('Hello ' + name),
]),
);
return {
DOM: vdom$,
};
}
run(main, {
DOM: makeDOMDriver('#main-container'),
});
开发者ID:joeldentici,项目名称:cyclejs,代码行数:30,代码来源:index.ts
示例10: routerify
const mainWithRouter = routerify(main, switchPath, {
historyName: "History",
routerName: "Router"
});
function helixPiDriver(sink$: Stream<Input>) {
const worker = work(require("./worker"));
const driver = makeWebWorkerDriver(worker);
const stringifiedSink$ = sink$.map(event => JSON.stringify(event));
return driver(stringifiedSink$).map(source => JSON.parse(source));
}
const drivers = {
DOM: makeDOMDriver(document.body),
Time: timeDriver,
History: makeHistoryDriver(),
DB: makeIDBDriver("helix-pi", 1, (upgradeDb: any) => {
const projectsStore = upgradeDb.createObjectStore("projects", {
keyPath: "id"
});
projectsStore.createIndex("id", "id");
}),
HelixPi: helixPiDriver
};
run(mainWithRouter, drivers);
开发者ID:helix-pi,项目名称:helix-pi,代码行数:29,代码来源:editor.ts
注:本文中的@cycle/run.run函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论