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


TypeScript virtual-dom.create函数代码示例

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


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

示例1: render

export const mount = <Stores>(
  render: (any) => VNode,
  stores: Stores,
  element: HTMLElement) => {
  element.innerHTML = "";
  let tree = render(stores);
  let rootNode = create(tree);
  element.appendChild(rootNode);
  
  for(let storeName of Object.keys(stores)){
    stores[storeName].subscribe(() => {
      let newTree = render(stores);
      let patches = diff(tree, newTree);
      rootNode    = patch(rootNode, patches);
      tree        =  newTree;
    })
  }
}
开发者ID:tomjal,项目名称:tsf,代码行数:18,代码来源:core.ts

示例2: appendPosts

    private appendPosts(): void {
        let newCollectionNode = new PostCollectionView(this.loadedPosts).render();

        if (!this.collectionElement) {
            this.collectionElement = create(newCollectionNode);
            let postElements = this.element.querySelectorAll(".post");
            let lastElement = postElements[postElements.length - 1];
            if (lastElement && lastElement.parentElement) {
                lastElement.parentElement.insertBefore(
                    this.collectionElement,
                    lastElement.nextSibling,
                );
            }
        } else {
            let patches = diff(this.collectionNode, newCollectionNode);
            this.collectionElement = patch(this.collectionElement, patches);
        }

        this.collectionNode = newCollectionNode;
    }
开发者ID:pxfs,项目名称:fanboi2,代码行数:20,代码来源:topic_load_posts.ts

示例3: h

/// <reference path="../typings/tsd.d.ts" />
/// <reference path="../manual-typings/vdom-virtualize.d.ts" />
/// <reference path="../manual-typings/immutable.d.ts" />
/// <reference path="../manual-typings/custom-window.d.ts" />
/// <reference path="../jspm_packages/npm/monapt@0.5.0/dist/monapt.d.ts" />

import { VPatch, diff, patch, h, create } from 'virtual-dom';
import { List, Map, Record, Iterable } from 'immutable';
import renderPage from './render';
import { getDeploys, getBuild, getDifference } from './api';
import { DeployRecord } from './model';
import { getMostRecentDeploys } from './model-helpers';

let currentTree = h('div', {}, []);
let rootNode: Element = create(currentTree);
document.body.appendChild(rootNode);

const updateDom = (newTree: VirtualDOM.VNode): void => {
    const patches: VPatch[] = diff(currentTree, newTree);
    rootNode = patch(rootNode, patches);
    currentTree = newTree;
};

const run = (): Promise<void> => {
    // We only care about servers which are deployed frequently and manually
    // with goo
    const serverWhitelist = List([
        'admin',
        'applications',
        'archive',
        'article',
开发者ID:315ea,项目名称:frontend,代码行数:31,代码来源:main.ts

示例4: Option

import { Option, Some, None } from 'monapt';

const headOption = <A>(array: Array<A>): Option<A> => Option(array[0]);

const { fetch } = window;

// https://github.com/Matt-Esch/virtual-dom/issues/276
const ih =
    (tagName: string,
     options: VirtualDOM.createProperties,
     children: List<VirtualDOM.VNode>): VirtualDOM.VNode => (
        h(tagName, options, children.toJS())
    );

let currentTree = h('div', {}, []);
let rootNode = create(currentTree);
document.body.appendChild(rootNode);

const updateDom = (newTree: VirtualDOM.VNode): void => {
    const patches = diff(currentTree, newTree);
    rootNode = patch(rootNode, patches);
    currentTree = newTree;
};

// A started deploy is all except status "Not running"
// This is because a deploy is not transactional, so we can't
// be sure if the box has updated or not once the job has started.
const hasDeployStarted = (deploy: DeployRecord) => deploy.status !== 'Not running';

const getStartedDeploysFor = (projectName: String, deploys: List<DeployRecord>) => (
    deploys
开发者ID:,项目名称:,代码行数:31,代码来源:


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