• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript common.prop函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: ctrl

export function ctrl(root: AnalyseCtrl) {
  const isOpen = prop(false),
  all = prop<any | null>(null);

  function loadGlyphs() {
    if (!all()) xhr.glyphs().then(function(gs) {
      all(gs);
      root.redraw();
    });
  };

  const toggleGlyph = throttle(500, false, function(id) {
    root.study!.makeChange('toggleGlyph', root.study!.withPosition({
      id
    }));
  });

  function open() {
    loadGlyphs();
    isOpen(true);
  };

  return {
    root,
    all,
    open,
    isOpen,
    toggle() {
      if (isOpen()) isOpen(false);
      else open();
    },
    toggleGlyph,
    redraw: root.redraw
  };
}
开发者ID:lexisvar,项目名称:lila,代码行数:35,代码来源:studyGlyph.ts


示例2: ctrl

export function ctrl(send: SocketSend, chapters: Prop<StudyChapterMeta[]>, setTab: () => void, root: AnalyseCtrl) {

  const multiPgnMax = 20;

  const vm = {
    variants: [],
    open: false,
    initial: prop(false),
    tab: storedProp('study.form.tab', 'init'),
    editor: null,
    editorFen: prop(null)
  };

  function loadVariants() {
    if (!vm.variants.length) xhrVariants().then(function(vs) {
      vm.variants = vs;
      root.redraw();
    });
  };

  function open() {
    vm.open = true;
    loadVariants();
    vm.initial(false);
  }
  function close() {
    vm.open = false;
  }

  return {
    vm,
    open,
    root,
    openInitial() {
      open();
      vm.initial(true);
    },
    close,
    toggle() {
      if (vm.open) close();
      else open();
    },
    submit(d) {
      d.initial = vm.initial();
      d.sticky = root.study!.vm.mode.sticky;
      if (!d.pgn) send("addChapter", d);
      else importPgn(root.study!.data.id, d);
      close();
      setTab();
    },
    chapters,
    startTour: () => chapterTour(tab => {
      vm.tab(tab);
      root.redraw();
    }),
    multiPgnMax,
    redraw: root.redraw
  }
}
开发者ID:luanlv,项目名称:lila,代码行数:59,代码来源:chapterNewForm.ts


示例3: ctrl

export function ctrl(root: AnalyseCtrl): CommentForm {

  const current = prop<Current | null>(null),
  focus = prop(false),
  opening = prop(false);

  function submit(text: string): void {
    if (!current()) return;
    doSubmit(text);
  };

  const doSubmit = throttle(500, (text: string) => {
    const cur = current();
    if (cur) root.study!.makeChange('setComment', {
      ch: cur.chapterId,
      path: cur.path,
      text
    });
  });

  function start(chapterId: string, path: Tree.Path, node: Tree.Node): void {
    opening(true);
    current({
      chapterId,
      path,
      node
    });
    root.userJump(path);
  };

  return {
    root,
    current,
    focus,
    opening,
    submit,
    start,
    onSetPath(chapterId: string, path: Tree.Path, node: Tree.Node, playedMyself: boolean): void {
      setTimeout(() => {
        const cur = current();
        if (cur && (path !== cur.path || chapterId !== cur.chapterId) && (!focus() || playedMyself)) {
          cur.chapterId = chapterId;
          cur.path = path;
          cur.node = node;
          root.redraw();
        }
      }, 100);
    },
    redraw: root.redraw,
    delete(chapterId: string, path: Tree.Path, id: string) {
      root.study!.makeChange('deleteComment', {
        ch: chapterId,
        path,
        id
      });
    }
  };
}
开发者ID:luanlv,项目名称:lila,代码行数:58,代码来源:commentForm.ts


示例4: ctrl

export function ctrl(root: AnalyseCtrl, chapterId: () => string): ServerEvalCtrl {

  const requested = prop(false),
  lastPly = prop<number | false>(false),
  chartEl = prop<HTMLElement | null>(null);

  function unselect(chart) {
    chart.getSelectedPoints().forEach(p => p.select(false));
  }

  li.pubsub.on('analysis.change', (_fen: string, _path: string, mainlinePly: number | false) => {
    if (!li.advantageChart || lastPly() === mainlinePly) return;
    const lp = lastPly(typeof mainlinePly === 'undefined' ? lastPly() : mainlinePly),
    el = chartEl();
    if (el && window.Highcharts) {
      const $chart = $(el);
      if ($chart.length) {
        const chart = $chart.highcharts();
        if (chart) {
          if (lp === false) unselect(chart);
          else {
            const point = chart.series[0].data[lp - 1 - root.tree.root.ply];
            if (defined(point)) point.select();
            else unselect(chart);
          }
        } else lastPly(false);
      }
    } else lastPly(false);
  });

  return {
    root,
    reset() {
      requested(false);
      lastPly(false);
    },
    chapterId,
    onMergeAnalysisData() {
      if (li.advantageChart) li.advantageChart.update(root.data);
    },
    request() {
      root.socket.send('requestAnalysis', chapterId());
      requested(true);
    },
    requested,
    lastPly,
    chartEl
  };
}
开发者ID:mate-amargo,项目名称:lila,代码行数:49,代码来源:serverEval.ts


示例5: make

export function make(opts): EvalCache {
  const fenFetched: string[] = [];
  function hasFetched(node): boolean {
    return fenFetched.includes(node.fen);
  };
  let upgradable = prop(false);
  return {
    onCeval: throttle(500, function() {
      const node = opts.getNode(), ev = node.ceval;
      if (ev && !ev.cloud && hasFetched(node) && qualityCheck(ev) && opts.canPut(node)) {
        opts.send("evalPut", toPutData(opts.variant, ev));
      }
    }),
    fetch(path: Tree.Path, multiPv: number): void {
      const node = opts.getNode();
      if ((node.ceval && node.ceval.cloud) || !opts.canGet(node)) return;
      if (hasFetched(node)) return;
      fenFetched.push(node.fen);
      const obj: any = {
        fen: node.fen,
        path
      };
      if (opts.variant !== 'standard') obj.variant = opts.variant;
      if (multiPv > 1) obj.mpv = multiPv;
      if (upgradable()) obj.up = true;
      opts.send("evalGet", obj);
    },
    onCloudEval(serverEval): void {
      opts.receive(toCeval(serverEval), serverEval.path);
    },
    upgradable
  };
};
开发者ID:ornicar,项目名称:lila,代码行数:33,代码来源:evalCache.ts


示例6: ctrl

export function ctrl(save: (data: FormData, isNew: boolean) => void, getData: () => StudyData, redraw: () => void, relay?: RelayCtrl): StudyFormCtrl {

  const initAt = Date.now();

  function isNew(): boolean {
    const d = getData();
    return d.from === 'scratch' && !!d.isNew && Date.now() - initAt < 9000;
  }

  const open = prop(false);

  return {
    open,
    openIfNew() {
      if (isNew()) open(true);
    },
    save(data: FormData, isNew: boolean) {
      save(data, isNew);
      open(false);
    },
    getData,
    isNew,
    redraw,
    relay
  };
}
开发者ID:ddugovic,项目名称:lila,代码行数:26,代码来源:studyForm.ts


示例7: ctrl

export function ctrl(root: AnalyseCtrl) {

  const all = prop<any | null>(null);

  function loadGlyphs() {
    if (!all()) xhr.glyphs().then(gs => {
      all(gs);
      root.redraw();
    });
  };

  const toggleGlyph = throttle(500, (id: string) => {
    root.study!.makeChange('toggleGlyph', root.study!.withPosition({
      id
    }));
  });

  return {
    root,
    all,
    loadGlyphs,
    toggleGlyph,
    redraw: root.redraw
  };
}
开发者ID:ddugovic,项目名称:lila,代码行数:25,代码来源:studyGlyph.ts


示例8: ctrl

export function ctrl(initChapters: StudyChapterMeta[], send: SocketSend, setTab: () => void, chapterConfig, root: AnalyseCtrl): StudyChaptersCtrl {

  const list: Prop<StudyChapterMeta[]> = prop(initChapters);

  const newForm = chapterNewForm(send, list, setTab, root);
  const editForm = chapterEditForm(send, chapterConfig, root.redraw);

  const localPaths: LocalPaths = {};

  return {
    newForm,
    editForm,
    list,
    get(id) {
      return list().find(c => c.id === id);
    },
    size() {
      return list().length;
    },
    sort(ids) {
      send("sortChapters", ids);
    },
    firstChapterId() {
      return list()[0].id;
    },
    toggleNewForm() {
      if (newForm.vm.open || list().length < 64) newForm.toggle();
      else alert("You have reached the limit of 64 chapters per study. Please create a new study.");
    },
    localPaths
  };
}
开发者ID:ddugovic,项目名称:lila,代码行数:32,代码来源:studyChapters.ts


示例9: ctrl

export function ctrl(data: StudyData, currentChapter: () => StudyChapterMeta, currentNode: () => Tree.Node, redraw: () => void) {
  const open = prop(false);
  const withPly = prop(false);
  return {
    open,
    toggle() {
      open(!open());
    },
    studyId: data.id,
    chapter: currentChapter,
    isPublic() {
      return data.visibility === 'public';
    },
    currentNode,
    withPly,
    cloneable: data.features.cloneable,
    redraw
  }
}
开发者ID:lexisvar,项目名称:lila,代码行数:19,代码来源:studyShare.ts


示例10: return

 return (fen: Fen): JQueryPromise<OpeningData> => {
   if (masterCache[fen]) return $.Deferred().resolve(masterCache[fen]).promise() as JQueryPromise<OpeningData>;
   return xhr.opening(opts.endpoint, 'standard', fen, {
     db: {
       selected: prop('masters')
     }
   }, false).then((res: OpeningData) => {
     masterCache[fen] = res;
     return res;
   });
 }
开发者ID:mate-amargo,项目名称:lila,代码行数:11,代码来源:explorerCtrl.ts



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript common.storedProp函数代码示例发布时间:2022-05-25
下一篇:
TypeScript common.empty函数代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap