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


TypeScript tassign.tassign函数代码示例

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


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

示例1: LocationInsertCompleteAction

 .subscribe((v) => {
     if (vh.isNew) {
         this._store.dispatch(new LocationInsertCompleteAction(tassign(vh, { Location: v })));
     } else {
         this._store.dispatch(new LocationUpdateCompleteAction(tassign(vh, { Location: v })));
     }
 });
开发者ID:rthiney,项目名称:sample-ng2-mvc,代码行数:7,代码来源:location-orchestrator.service.ts

示例2: PersonInsertCompleteAction

 .subscribe((p) => {
     if (h.isNew) {
         this._store.dispatch(new PersonInsertCompleteAction(tassign(h, { Person: p })));
     } else {
         this._store.dispatch(new PersonUpdateCompleteAction(tassign(h, { Person: p })));
     }
 });
开发者ID:rthiney,项目名称:sample-ng2-mvc,代码行数:7,代码来源:person-orchestrator.service.ts

示例3: toggleTodo

function toggleTodo(state, action) {
  var todo = state.todos.find(t => t.id === action.id);

  // Now, we need to find the position of this item in the array.
  var index = state.todos.indexOf(todo);

  return tassign(state, {
    todos: [
      ...state.todos.slice(0, index),
      tassign(todo, { isCompleted: !todo.isCompleted }),
      ...state.todos.slice(index + 1),
    ],
    lastUpdate: new Date()
  });
}
开发者ID:ishara,项目名称:angular-redux-seed,代码行数:15,代码来源:todo.store.ts

示例4: allocationsStore

export function allocationsStore(state = initialState, action: Action & Value): AllocationsState {
  switch (action.type) {
    case Actions.SELECT_PROJECT:
      return tassign(state, {selectedProject: Maybe.some(action.value)});
    default:
      return state
  }
};
开发者ID:desmondrawls,项目名称:react-typescript,代码行数:8,代码来源:reducer.ts

示例5: addTodo

function addTodo(state, action) {
  var newTodo = { id: state.todos.length + 1, title: action.title };

  return tassign(state, {
    todos: state.todos.concat(newTodo),
    lastUpdate: new Date()
  });
}
开发者ID:ishara,项目名称:angular-redux-seed,代码行数:8,代码来源:todo.store.ts

示例6: searchReducer

export function searchReducer(
  state = INIT_STATE,
  action): ISearchState {

  switch (action.type) {
    case SEARCH_ACTIONS.SEARCH:
      return tassign(state, {
        onSearch: true,
        keyword: action.payload,
        total: state.total
      });
    case SEARCH_ACTIONS.SEARCH_RESULT:
      let total = action.payload.total;
      return tassign(state, {
        onSearch: state.onSearch,
        keyword: state.keyword,
        total
      });
    default:
      return state;
  }
}
开发者ID:veanyee,项目名称:store,代码行数:22,代码来源:search.reducer.ts

示例7: rootReducer

export function rootReducer(state, action) {
	switch(action.type) {
		case Actions.ADD_BOOK:
			//action.book.id = state.books.length + 1;
			return tassign(state, {
				books: state.books.concat(tassign({},action.book)),
				lastUpdate: new Date()
			});
		case Actions.REMOVE_BOOK:
			return tassign(state, {
				books: state.books.filter(b => b.key !== state.editedBook.key),
        		filteredBooks: state.filteredBooks.filter(b => b.key !== state.editedBook.key),
				lastUpdate: new Date()
			});	
		case Actions.LOAD_BOOKS:
			return tassign(state, {
			  	books: action.books,
					filteredBooks: action.books
			});
		case Actions.SEARCH_BOOK:
			return tassign(state,{
						filteredBooks: filterBooks(action, state),
						lastUpdated: new Date()
			});

		case Actions.LOAD_CATEGORIES:
			return tassign(state, {
				categories: action.categories
			});
		case Actions.ADD_CATEGORY:
			return tassign(state, {
				categories: state.categories.concat(tassign({},action.category)),
				lastUpdate: new Date()
			});
		case Actions.REMOVE_CATEGORY:
			var index = state.categories.indexOf(action.category);
			return tassign(state, {
				categories: [
					...state.categories.slice(0, index),
					...state.categories.slice(index+1)
				],
				lastUpdated: new Date()
			});


		case Actions.ADD_EDITED_BOOK:
			return tassign(state, {
				editedBook: action.editedBook
			});
		case Actions.REMOVE_EDITED_BOOK:
			return tassign(state, {
				editedBook: null
			});
		case Actions.LOAD_USER:
			return tassign(state, {
				user: action.user
			});
		case Actions.REMOVE_USER:
			return tassign(state, {
				user: null
			});

		case Actions.ADD_EXCEPTION:
			return tassign(state, {
				exception: action.exception
			});
		case Actions.REMOVE_EXCEPTION:		
			return tassign(state, {
				exception: null
			});

	}

	return state;
}
开发者ID:Leks12lk,项目名称:ng5-lib-note,代码行数:75,代码来源:store.ts

示例8: rootReducer

export function rootReducer(state: IAppState, action): IAppState {
    switch (action.type) {
        case ADD_TODO:
            var newTodo = { id: state.todos.length + 1, title: action.title };

            return tassign(state, {
                // Instead of the push() method, we use the concat() method because the former mutates
                // the original array, whereas the latter returns a new array. 
                todos: state.todos.concat(newTodo),
                lastUpdate: new Date()
            });

        case TOGGLE_TODO:
            // When modifying an item in an array, we should create a new array, and copy 
            // all other item from the source array (except the item to be modified). At the same time
            // we should create a copy of the item to be modified and apply the mutations using tassing.

            // So, first we need to find the item to be modified. Here, we are finding it by it's id. 
            var todo = state.todos.find(t => t.id === action.id);

            // Now, we need to find the position of this item in the array. 
            var index = state.todos.indexOf(todo);

            return tassign(state, {
                todos: [
                    // Using the slice() method, we can slice an array. This method does not mutate the 
                    // original array, and returns a new array. So here, we're getting all the items from 
                    // the beginning to the index of the item we're going to modiy. 
                    // 
                    // We use the spread operator (...) to enumerate an array. This is a clean way to 
                    // concat two arrays. Instead of 
                    // 
                    // var newArray = [];
                    // newArray.concat(sourceArray1).concat(sourceArray2);
                    // 
                    // We can write: 
                    // 
                    // var newArray = [...sourceArray1, ...sourceArray2];
                    ...state.todos.slice(0, index),

                    // So, we have copied all the items before the item to be modified. Now, we take a copy
                    // of this item and apply the mutation (isCompleted).
                    tassign(todo, { isCompleted: !todo.isCompleted }),

                    // Now, we need to copy all the items after this item. Again, we use the slice() method
                    // to get all the items following that item, and use the spread operator to enumerate 
                    // them and put them in our target array. 
                    ...state.todos.slice(index + 1),
                ],
                lastUpdate: new Date()
            });

        case REMOVE_TODO:
            return tassign(state, {
                todos: state.todos.filter(t => t.id !== action.id),
                lastUpdate: new Date()
            });

        case CLEAR_TODOS:
            return tassign(state, {
                todos: [],
                lastUpdate: new Date()
            });
    }

    return state;
}
开发者ID:dhananjay12,项目名称:learn-angular,代码行数:67,代码来源:store.ts

示例9: clearTodos

function clearTodos(state, action) {
  return tassign(state, {
    todos: [],
    lastUpdate: new Date()
  });
}
开发者ID:ishara,项目名称:angular-redux-seed,代码行数:6,代码来源:todo.store.ts

示例10: removeTodo

function removeTodo(state, action) {
  return tassign(state, {
    todos: state.todos.filter(t => t.id !== action.id),
    lastUpdate: new Date()
  });
}
开发者ID:ishara,项目名称:angular-redux-seed,代码行数:6,代码来源:todo.store.ts


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