markdown 动作创作者

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了markdown 动作创作者相关的知识,希望对你有一定的参考价值。

## Dans actions

```
// todo.actions.ts
import { Action } from '@ngrx/store';

export const ADD_TODO = '[Todo] Add Todo';
export const REMOVE_TODO = '[Todo] Remove Todo';

export class AddTodo implements Action {
  readonly type = ADD_TODO;
  constructor(public payload: Todo) {}
}

export class RemoveTodo implements Action {
  readonly type = REMOVE_TODO;
  constructor(public payload: Todo) {}
}

// exporting a custom type
export type TodoActions = AddTodo | RemoveTodo;
```
// todo.reducers.ts

```
import * as fromActions from './todo.actions';

export interface TodoState {
  loaded: boolean;
  loading: boolean;
  data: Todo[];
}

export const initialState: TodoState = {
  loaded: false,
  loading: false,
  data: [],
};

export function reducer(
  state: TodoState = initialState, 
  action: fromActions.TodoActions`
) {
  switch (action.type) {
    case fromActions.ADD_TODO: {
      const data = [...state.data, action.payload];
      return { ...state, data };
    }

    case fromActions.REMOVE_TODO: {
      const data = state.data.filter(
        todo => todo.label !== action.payload.label
      );
      return { ...state, data };
    }
  }

  return state;
}
```
// todo.component.ts
```
this.store.dispatch(
  fromActions.AddTodo({ label: 'Eat pizza', complete: false })
);
```

以上是关于markdown 动作创作者的主要内容,如果未能解决你的问题,请参考以下文章

markdown gpg关键动作

markdown 浮动动作按钮提示和技巧

markdown 动作条添加菜单

markdown 动作条的相关配置

markdown 动作条と工具栏が両方表示される

markdown Menempatkan动作快捷方式在Visual Studio Code di工具栏中打开Finder App MacOS untuk langsung membuka文件夹yang