本文整理汇总了TypeScript中Immutable.fromJS函数的典型用法代码示例。如果您正苦于以下问题:TypeScript fromJS函数的具体用法?TypeScript fromJS怎么用?TypeScript fromJS使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了fromJS函数的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: fromJS
/**
* Copyright(c) dtysky<[email protected]>
* Created: 9 Nov 2017
* Description:
*/
import {Record, fromJS} from 'immutable';
import {TModal} from '../types';
import {definitions} from '../actions';
export const defaultState: TModal = fromJS({
type: 'info',
message: '',
show: false,
onConfirm: () => {},
onCancel: () => {}
});
const genNewState = (type: string, action: {
type: string,
message?: string,
onConfirm?: () => void,
onCancel?: () => void
}) => (
{
type, show: true, message: action.message,
onConfirm: action.onConfirm, onCancel: action.onCancel
}
);
export default (state = defaultState, action: {
type: string,
开发者ID:dtysky,项目名称:MoeNotes,代码行数:31,代码来源:modal.ts
示例2: fromJS
import * as ActionTypes from '../actions/app';
import { Action } from '../actions/action';
import { fromJS, Map } from 'immutable';
const INITIAL_STATE = fromJS({
title: 'medCPU UI Starter'
});
function setTitle(state, action: Action) {
return state.set('title', action.payload.title);
}
export default function app(
state = INITIAL_STATE,
action: Action = {type: ''}): Map<string, any> {
switch (action.type) {
case ActionTypes.APP_SET_TITLE:
return setTitle(state, action);
}
return state;
};
开发者ID:levinmr,项目名称:angular2-webpack-redux,代码行数:23,代码来源:app.ts
示例3: it
it("can log in a different user", () => {
const action = { type: LOGIN_SUCCESS, payload: { userId: 'jdavis', displayName: 'Jen' } };
expect(SessionReducer(state, action)).toEqualImmutable(fromJS({ userId: 'jdavis', displayName: 'Jen' }));
});
开发者ID:PhilipDavis,项目名称:react-redux,代码行数:4,代码来源:SessionReducer_spec.ts
示例4: fromJS
return state.withMutations((s) => s
.set("error", error)
.set("input", input)
.set("valid", valid)
.set("vars", fromJS(vars))
.set("results", results));
开发者ID:shuntksh,项目名称:binaryscanr,代码行数:6,代码来源:module.ts
示例5: fromJS
import {
LOGIN_USER_PENDING,
LOGIN_USER_SUCCESS,
LOGIN_USER_ERROR,
LOGOUT_USER,
} from '../constants';
import { fromJS } from 'immutable';
const INITIAL_STATE = fromJS({
token: null,
user: {},
hasError: false,
isLoading: false,
});
function sessionReducer(state = INITIAL_STATE, action: any = {type: ''}) {
switch (action.type) {
case LOGIN_USER_PENDING:
return state.merge(fromJS({
token: null,
user: {},
hasError: false,
isLoading: true,
}));
case LOGIN_USER_SUCCESS:
return state.merge(fromJS({
token: action.payload.token,
user: action.payload.profile,
开发者ID:BrendanFDMoore,项目名称:angular2-redux-starter,代码行数:31,代码来源:session.ts
示例6: it
it('flattening a List returns a List', () => {
var nested = fromJS([[1],2,3,[4,5,6]]);
var flat = nested.flatten();
expect(flat.toString()).toEqual("List [ 1, 2, 3, 4, 5, 6 ]");
})
开发者ID:Harishs84,项目名称:immutable-js,代码行数:5,代码来源:flatten.ts
示例7: fromJS
const data = fromJS([
{
"_id": "56e18ce608c0a0190da963f8",
"index": 0,
"guid": "5e0dbf88-33f1-4b84-bdca-ac21719bf0e8",
"isActive": false,
"balance": "$1,284.82",
"picture": "http://placehold.it/32x32",
"age": 36,
"eyeColor": "blue",
"name": {
"first": "Lauren",
"last": "Stanley"
},
"company": "HAIRPORT",
"email": "[email protected]",
"phone": "+1 (876) 425-2958",
"address": "456 Front Street, Wacissa, Virginia, 9236",
"about": "Dolor aliqua enim irure mollit. Sunt ullamco laborum reprehenderit labore. Eu consequat laborum consectetur voluptate laborum fugiat quis tempor amet nulla. Irure duis reprehenderit irure officia sit magna deserunt. Incididunt eu aliquip proident id amet enim dolor reprehenderit ut ipsum est elit ea.",
"registered": "Friday, August 8, 2014 4:08 PM",
"latitude": "41.628375",
"longitude": "104.950835",
"tags": [
7,
"veniam"
],
"range": [
0,
1,
2,
3,
4,
5,
6,
7,
8,
9
],
"friends": [
3,
{
"id": 1,
"name": "Mccall Petersen"
}
],
"greeting": "Hello, Lauren! You have 9 unread messages.",
"favoriteFruit": "banana"
},
{
"_id": "56e18ce6dc7d5ade1e3c7889",
"index": 1,
"guid": "7ceca65c-cc8d-4f88-ab00-b5d00b72e27f",
"isActive": true,
"balance": "$1,423.68",
"picture": "http://placehold.it/32x32",
"age": 35,
"eyeColor": "brown",
"name": {
"first": "Schmidt",
"last": "Floyd"
},
"company": "ANIXANG",
"email": "[email protected]",
"phone": "+1 (913) 595-3119",
"address": "274 Norfolk Street, Freeburn, Nevada, 1869",
"about": "Exercitation deserunt quis commodo ad qui aliqua proident mollit labore mollit. Deserunt occaecat in pariatur mollit aute consequat reprehenderit in deserunt magna ad. Aliquip labore do mollit officia laboris in aliquip magna aliqua. Sunt occaecat eiusmod ea amet dolore consectetur aute consequat adipisicing et nisi fugiat. Aute eiusmod quis duis ipsum occaecat culpa eiusmod Lorem amet laborum occaecat adipisicing minim. Labore exercitation laborum sint enim veniam labore officia. Aliquip do esse consectetur amet.",
"registered": "Sunday, October 12, 2014 8:17 AM",
"latitude": "-3.271053",
"longitude": "-124.321634",
"tags": [
7,
"veniam"
],
"range": [
0,
1,
2,
3,
4,
5,
6,
7,
8,
9
],
"friends": [
3,
{
"id": 1,
"name": "Mccall Petersen"
}
],
"greeting": "Hello, Schmidt! You have 9 unread messages.",
"favoriteFruit": "apple"
},
{
"_id": "56e18ce603784459df38b06c",
"index": 2,
"guid": "b19ffa1d-ca97-4e94-809e-3bf82df7fd40",
"isActive": true,
//.........这里部分代码省略.........
开发者ID:ShivKamal,项目名称:ngCourse2,代码行数:101,代码来源:exercise.ts
示例8: invites
import {fromJS, Map} from 'immutable';
// const _ = require('lodash');
import actionTypes from '../actionTypes';
const INIT_STATE = Map<string, any>(fromJS({
status: "UNSUBSCRIBED",
items: {}
}))
export default function invites(state:any = INIT_STATE, action:any = {}) {
console.log('action');
console.log(action);
switch (action && action.type) {
case actionTypes.INVITE_SUBSCRIBE_INIT:
return state.set('status', action.data.get('status'));
case actionTypes.INVITE_SUBSCRIBE_SUCCESS:
return state.set('status', action.data.get('status'));
case actionTypes.INVITE_SUBSCRIBE_FAIL:
return state.set('status', action.data.get('status'));
case actionTypes.INVITE_FETCH_INIT:
return state.set('status', action.data.get('status'));
case actionTypes.INVITE_FETCH_SUCCESS:
return state.set('items', state.get('items').merge(action.data.get('items')));
case actionTypes.INVITE_FETCH_FAIL:
// return state.set('items', state.get('items').delete(action.data.get('objectId')));
case actionTypes.INVITE_DELETE_INIT:
return state.set('status', action.data.get('status'));
case actionTypes.INVITE_DELETE_SUCCESS:
return state.set('items', state.get('items').delete(action.data.get('objectId')));
开发者ID:hack4change,项目名称:hambasafe-client,代码行数:31,代码来源:invites.ts
示例9: fromJS
import {
INCREMENT_COUNTER,
DECREMENT_COUNTER,
LOGOUT_USER
} from '../constants';
import { fromJS, Map } from 'immutable';
export interface CounterState extends Map<string, any> {
}
const INITIAL_STATE = fromJS({
count: 0,
});
function counterReducer(state: CounterState = INITIAL_STATE,
action = { type: '' }): CounterState {
switch (action.type) {
case INCREMENT_COUNTER:
return state.update('count', (value) => value + 1);
case DECREMENT_COUNTER:
return state.update('count', (value) => value - 1);
case LOGOUT_USER:
return state.merge(INITIAL_STATE);
default:
return state;
}
}
开发者ID:e-schultz,项目名称:angular2-redux-example,代码行数:31,代码来源:counter.ts
注:本文中的Immutable.fromJS函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论