当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript cycle-onionify.default函数代码示例

本文整理汇总了TypeScript中cycle-onionify.default函数的典型用法代码示例。如果您正苦于以下问题:TypeScript default函数的具体用法?TypeScript default怎么用?TypeScript default使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了default函数的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: normalize

  appElement.innerHTML = '<h2>You appear to be using Internet Explorer<br/>It would be a good time to examine the life choices that have led you to this moment</h2>'
  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,代码行数:31,代码来源:index.ts

示例2: wrapMain

export function wrapMain(main: Component): Component {
    return routerify(
        onionify(
            storageify(auth0ify(main, AUTH0IFY_OPTIONS) as any, {
                key: 'brian-state',
                debounce: 100 // wait for 100ms without state change before writing to localStorage
            })
        ),
        switchPath as RouteMatcher
    ) as any
}
开发者ID:OpenDirective,项目名称:brian,代码行数:11,代码来源:drivers.ts

示例3: withTime

                withTime(Time => {
                    const add$ = Time.diagram(addDiagram)
                    const subtract$ = Time.diagram(subtractDiagram)

                    const DOM = mockDOMSource({
                        '.add': { click: add$ },
                        '.subtract': { click: subtract$ }
                    })

                    const app = onionify(App)({ DOM } as any)
                    const html$ = (app.DOM as Stream<VNode>).map(toHtml)

                    const expected$ = xs
                        .merge(add$.mapTo(+1), subtract$.mapTo(-1))
                        .fold((acc, curr) => acc + curr, 0)
                        .map(expectedHTML)

                    Time.assertEqual(html$, expected$, htmlLooksLike)
                })
开发者ID:OpenDirective,项目名称:brian,代码行数:19,代码来源:app.test.ts

示例4: promise

        const property = forall(diagramArbitrary, diagramArbitrary, (addDiagram, subtractDiagram) => {
            const Time = mockTimeSource();

            const add$ = Time.diagram(addDiagram);
            const subtract$ = Time.diagram(subtractDiagram);

            const DOM = mockDOMSource({
                '.add': { click: add$ },
                '.subtract': { click: subtract$ }
            });

            const app = onionify(App)({ DOM } as any);
            const html$ = app.DOM.map(toHtml);

            const expected$ = xs.merge(add$.mapTo(+1), subtract$.mapTo(-1))
                .fold((acc, curr) => acc + curr, 0)
                .map(expectedHTML);

            Time.assertEqual(html$, expected$, htmlLooksLike);
            return promise(Time.run);
        });
开发者ID:michalvankodev,项目名称:portfolio,代码行数:21,代码来源:app.test.ts

示例5: ProjectWithDB

function ProjectWithDB(sources: ISources) {
  const projectResult$ = sources.DB.store("projects").get(sources.id);

  const initialState$ = projectResult$.filter(Boolean) as Stream<Project>;

  const project = onionify(Project)({ ...sources, initialState$ });

  const initialPersistence$ = projectResult$
    .filter((project: Project | undefined) => project === undefined)
    .mapTo($add("projects", makeProject(sources.id as string)));

  const updatePersistence$ = (project as any).state$.map((state: Project) =>
    $update("projects", state)
  );

  return {
    ...project,

    DB: xs.merge(initialPersistence$, updatePersistence$)
  };
}
开发者ID:helix-pi,项目名称:helix-pi,代码行数:21,代码来源:editor.ts


注:本文中的cycle-onionify.default函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。