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


TypeScript Immutable.Record函数代码示例

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


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

示例1: it

  it('supports imbricated Record {min: false}', () => {
    const CDRecord = Immutable.Record({c: 3, d: 4}, 'CDRecord');
    const ABRecord = Immutable.Record({a: CDRecord(), b: 2}, 'ABRecord');

    expect(ABRecord()).toPrettyPrintTo(
      'Immutable.ABRecord {\n  "a": Immutable.CDRecord {\n    "c": 3,\n    "d": 4,\n  },\n  "b": 2,\n}',
    );
  });
开发者ID:Volune,项目名称:jest,代码行数:8,代码来源:Immutable.test.ts

示例2: it

 it('passes through records of the same type', () => {
   var P2 = Record({ x: 0, y: 0 });
   var P3 = Record({ x: 0, y: 0, z: 0 });
   var p2 = P2();
   var p3 = P3();
   expect(P3(p2) instanceof P3).toBe(true);
   expect(P2(p3) instanceof P2).toBe(true);
   expect(P2(p2)).toBe(p2);
   expect(P3(p3)).toBe(p3);
 })
开发者ID:rexhome7326,项目名称:immutable-js,代码行数:10,代码来源:Record.ts

示例3: describe

describe('shared / model-helper', () => {

  interface Mock {
    prop1: string;
    prop2: string;
  }

  const MockModel: Record.Factory<Mock> = Record<Mock>({
    prop1: '',
    prop2: ''
  });

  describe('generateMap', () => {

    const mockData: Mock[] = [
      { prop1: 'value10', prop2: 'value10' },
      { prop1: 'value11', prop2: 'value21' },
      { prop1: 'value12', prop2: 'value22' }
    ];

    it('should return an Immutable Map', () => {
      const expectedMap = Map([
        [0, new MockModel(mockData[0])],
        [1, new MockModel(mockData[1])],
        [2, new MockModel(mockData[2])]
      ]);

      expect(generateMap(mockData, MockModel).toObject()).to.deep.equal(expectedMap.toObject());
    });
  });
});
开发者ID:atSistemas,项目名称:angular-base,代码行数:31,代码来源:ModelHelper.shared.spec.ts

示例4: builds

export default function builds(state = initialState["builds"], action) {
    switch (action.type) {

        case actionTypes.CLEAR_BUILD:
            return state
                .setIn(["selected", "info"], Record({})());

        case actionTypes.CLEAR_BUILD_LOG:
            state.get("selected").log.content.next([]);

            return state.setIn(["selected", "log"], {
                start: undefined,
                stop: undefined,
                content: state.get("selected").log.content,
                is_complete: undefined
            });

        case actionTypes.CLEAR_BUILDS:
            return state
                .setIn(["visible"], List());

        case actionTypes.POPULATE_BUILD:
            return state.setIn(["selected", "info"], action.payload);

        case actionTypes.POPULATE_BUILD_LOG:
            let payload = action.payload;
            let content = state.get("selected").log.content;

            // It'll be common to get log requests for builds that haven't
            // started yet (which will surface as errors), so in that case,
            // we'll just hand back the current state.
            if (action.error) {
                return state;
            }

            if (payload.start === 0 && !payload.is_complete) {
                content.next(payload.content || []);
            }
            else if (payload.content.length) {
                content.next(payload.content);
            }

            return state.setIn(["selected", "log"], {
                start: payload.start,
                stop: payload.stop,
                content: content,
                is_complete: payload.is_complete
            });

        case actionTypes.POPULATE_BUILDS:
            return state.setIn(["visible"], List(action.payload));

        case actionTypes.STREAM_BUILD_LOG:
            return state.setIn(["selected", "stream"], action.payload);

        default:
            return state;
    }
}
开发者ID:rx007,项目名称:habitat,代码行数:59,代码来源:builds.ts

示例5: Record

export function makeTypedFactory<E, T extends TypedRecord<T> & E>
  (obj: E, name?: string): (val?: E) => T {

  const ImmutableRecord = Record(obj, name);
  return function TypedFactory(val: E = null): T {
    return new ImmutableRecord(val) as T;
  };
};
开发者ID:rangle,项目名称:typed-immutable-record,代码行数:8,代码来源:typed.factory.ts


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