本文整理汇总了TypeScript中seamless-immutable.default方法的典型用法代码示例。如果您正苦于以下问题:TypeScript seamless-immutable.default方法的具体用法?TypeScript seamless-immutable.default怎么用?TypeScript seamless-immutable.default使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类seamless-immutable
的用法示例。
在下文中一共展示了seamless-immutable.default方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: switch
import { ActionReducer, Action } from '@ngrx/store';
import * as SI from 'seamless-immutable';
import { CoreActions } from '../actions/core.actions';
import { CoreUIState } from '../models/core.ui.state';
let initVal: CoreUIState & Immutable.ObjectMethods<CoreUIState> = SI<CoreUIState>( { menuOpen: false } );
export const core_ui: ActionReducer<CoreUIState & Immutable.ObjectMethods<CoreUIState>> = (curr = initVal, action: Action) => {
switch (action.type) {
case CoreActions.MENU_TOGGLED:
return curr.set( 'menuOpen', !curr.menuOpen );
default:
return curr;
}
};
示例2: expect
expect(() => calculateFixedColumnProps(
{ tableColumn: findColumnByName('e1') },
{ leftColumns: ['a', 'b0', 'b1', 'b2', 'c'], rightColumns: ['d', 'e0', 'e1', 'e2', 'f'] },
Immutable(extendedTableColumns),
{},
extendedColumnChains,
)).not.toThrow();
示例3: it
it('should work with immutable properties', () => {
const state = { sorting: Immutable([{ columnName: 'test', direction: 'asc' }]) };
expect(() => changeColumnSorting(state, { columnName: 'test2', keepOther: true }))
.not.toThrow();
expect(() => changeColumnSorting(state, { columnName: 'test2', keepOther: ['test'] }))
.not.toThrow();
});
示例4: it
it('should collapse Immutable rows', () => {
/* tslint:disable ter-indent align */
const rows = Immutable([
{ a: 0 },
{ a: 1 },
{ a: 1, b: 1 },
{ a: 1, b: 1, c: 1 },
{ a: 2 },
{ a: 2, b: 1 },
{ a: 2, b: 1, c: 1 },
]);
/* tslint:enable ter-indent align */
const linearizedRows = {
rows,
treeMeta: new Map([
[rows[0], { level: 0 }],
[rows[1], { level: 0 }],
[rows[2], { level: 1 }],
[rows[3], { level: 2 }],
[rows[4], { level: 0 }],
[rows[5], { level: 1 }],
[rows[6], { level: 2 }],
]),
};
const getRowId = row => rows.indexOf(row);
const expandedLinearizedRows = {
/* tslint:disable ter-indent align */
rows: [
{ a: 0 },
{ a: 1 },
{ a: 1, b: 1 },
{ a: 2 },
],
/* tslint:enable ter-indent align */
treeMeta: linearizedRows.treeMeta,
collapsedRowsMeta: new Map([
[rows[2], [rows[3]]],
[rows[4], [rows[5], rows[6]]],
]),
};
expect(expandedTreeRows(linearizedRows, getRowId, expandedRowIds))
.toEqual(expandedLinearizedRows);
});
示例5: Immutable
interface ExtendedUser extends User {
address: Address;
}
//
// Constructors
// ---------------------------------------------------------------
{
interface User {
firstName: string;
lastName: string;
}
const arrayOfNumbers1: Immutable.ImmutableArray<number> = Immutable.from([0, 2]);
const arrayOfNumbers2: Immutable.ImmutableArray<number> = Immutable([0, 2]);
const user1: Immutable.ImmutableObject<User> = Immutable.from({
firstName: 'Angry',
lastName: 'Monkey'
});
const user2: Immutable.ImmutableObject<User> = Immutable({
firstName: 'Angry',
lastName: 'Monkey'
});
const error: Error = Immutable.ImmutableError('error');
}
//
// Static utilities
// ---------------------------------------------------------------