當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript Immutable.fromJS函數代碼示例

本文整理匯總了TypeScript中Immutable.fromJS函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript fromJS函數的具體用法?TypeScript fromJS怎麽用?TypeScript fromJS使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了fromJS函數的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: fromJS

/**
 * Copyright(c) dtysky<dtysky@outlook.com>
 * 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": "lauren.stanley@hairport.name",
    "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": "schmidt.floyd@anixang.org",
    "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;未經允許,請勿轉載。