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


TypeScript Graph.get方法代码示例

本文整理汇总了TypeScript中external/gs_tools/src/graph.Graph.get方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Graph.get方法的具体用法?TypeScript Graph.get怎么用?TypeScript Graph.get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在external/gs_tools/src/graph.Graph的用法示例。


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

示例1: it

    it(`should setup correctly`, async () => {
      const inputEl = Mocks.object('inputEl');
      spyOn(input, 'getInputEl_').and.returnValue(Promise.resolve(inputEl));

      const mockDisposable = jasmine.createSpyObj('Disposable', ['dispose']);
      const spyListen = spyOn(input, 'listenToValueChanges_').and.returnValue(mockDisposable);

      const value = 'value';
      spyOn(input, 'getInputElValue_').and.returnValue(value);

      await input.onHostCreated_();
      assert(await Graph.get($inputValue, Graph.getTimestamp(), input)).to.equal(value);
      assert(input['getInputElValue_']).to.haveBeenCalledWith(inputEl);

      await inputValueProvider('other', input);

      assert(input['listenToValueChanges_']).to.haveBeenCalledWith(inputEl, Matchers.anyFunction());
      await spyListen.calls.argsFor(0)[1]();
      assert(await Graph.get($inputValue, Graph.getTimestamp(), input)).to.equal(value);
    });
开发者ID:garysoed,项目名称:gs-ui,代码行数:20,代码来源:base-input2_test.ts

示例2: async

        + `registration`, async () => {
      const triggeredBy = 'triggeredBy';
      spyOn(Persona, 'getValue').and.returnValue(triggeredBy);

      const origDisposable = DisposableFunction.of(() => undefined);
      Graph.createProvider($triggeredByRegistration, origDisposable);

      const mockTargetEl =
          jasmine.createSpyObj('TargetEl', ['addEventListener', 'removeEventListener']);

      const mockRootNode = jasmine.createSpyObj('RootNode', ['querySelector']);
      Object.setPrototypeOf(mockRootNode, Element.prototype);
      mockRootNode.querySelector.and.returnValue(mockTargetEl);

      const mockElement = jasmine.createSpyObj('Element', ['getRootNode']);
      mockElement.getRootNode.and.returnValue(mockRootNode);
      Object.setPrototypeOf(mockElement, HTMLElement.prototype);
      await Graph.createProvider($.host.el.getId(), mockElement);

      spyOn(menu, 'onTriggered_');

      await menu.onTriggeredByChanged_();
      const disposable = await Graph.get($triggeredByRegistration, Graph.getTimestamp(), menu);
      disposable!.dispose();
      assert(mockTargetEl.removeEventListener).to
          .haveBeenCalledWith('gs-action', Matchers.any(Function));

      const handler = mockTargetEl.removeEventListener.calls.argsFor(0)[1];
      assert(mockTargetEl.addEventListener).to.haveBeenCalledWith('gs-action', handler);
      assert(mockRootNode.querySelector).to.haveBeenCalledWith(triggeredBy);
      assert(origDisposable.isDisposed()).to.beTrue();

      const event = Mocks.object('event');
      handler(event);
      assert(Persona.getValue).to.haveBeenCalledWith($.host.triggeredBy, menu);
    });
开发者ID:garysoed,项目名称:gs-ui,代码行数:36,代码来源:menu_test.ts

示例3: staticId

    .addType(NullType)
    .build();
const $lastAction = staticId('lastAction', ActionType);
const lastActionProvider = Graph.createProvider($lastAction, null);

const TimestampType = UnionType.builder<number | null>()
    .addType(NumberType)
    .addType(NullType)
    .build();
const $lastActionTimestamp = staticId('lastActionTimestamp', TimestampType);
const lastActionTimestampProvider = Graph.createProvider($lastActionTimestamp, null);

export const ActionTracker = {
  async get(time: GraphTime): Promise<Action | null> {
    const [lastAction, lastActionTimestamp] = await Promise.all([
      Graph.get($lastAction, time),
      Graph.get($lastActionTimestamp, time),
    ]);

    if (lastActionTimestamp === null) {
      return null;
    }
    const now = Date.now();
    return (now - lastActionTimestamp) < MAX_ACTION_AGE_ ? lastAction : null;
  },

  async set(action: Action | null): Promise<void> {
    return Promise
        .all([
          lastActionProvider(action),
          lastActionTimestampProvider(Date.now()),
开发者ID:garysoed,项目名称:gs-ui,代码行数:31,代码来源:action-tracker.ts


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