當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。