Skip to content

Instantly share code, notes, and snippets.

@lydemann
Last active July 6, 2018 18:06
Show Gist options
  • Save lydemann/08cfe7210bbcf3cb2042d09440d4af68 to your computer and use it in GitHub Desktop.
Save lydemann/08cfe7210bbcf3cb2042d09440d4af68 to your computer and use it in GitHub Desktop.
import { Injectable } from '@angular/core';
import { TODOItem } from '@app/shared/models/todo-item';
import { GenericAction } from '@app/store/generic-action';
import { dispatch } from '@angular-redux/store';
export enum TodoListActionTypes {
TodoItemsLoaded = 'TodoItemsLoaded',
TodoItemCreated = 'TodoItemCreated',
TodoItemDeleted = 'TodoItemDeleted',
TodoItemUpdated = 'TodoItemUpdated',
TodoItemCompleted = 'TodoItemCompleted',
}
@Injectable()
export class TodoListActions {
constructor() {
}
@dispatch()
public todoItemsLoaded(payload: TODOItem[]): GenericAction<TodoListActionTypes, TODOItem[]> {
return {
type: TodoListActionTypes.TodoItemsLoaded,
payload: payload
};
}
@dispatch()
public todoItemCreated(todoItem: TODOItem): GenericAction<TodoListActionTypes, TODOItem> {
return {
type: TodoListActionTypes.TodoItemCreated,
payload: todoItem
};
}
@dispatch()
public todoItemDeleted(todoItem: TODOItem): GenericAction<TodoListActionTypes, TODOItem> {
return {
type: TodoListActionTypes.TodoItemDeleted,
payload: todoItem
};
}
@dispatch()
public todoItemUpdated(todoItem: TODOItem): GenericAction<TodoListActionTypes, TODOItem> {
return {
type: TodoListActionTypes.TodoItemUpdated,
payload: todoItem
};
}
@dispatch()
public todoItemCompleted(todoItem: TODOItem): GenericAction<TodoListActionTypes, TODOItem> {
return {
type: TodoListActionTypes.TodoItemCompleted,
payload: todoItem
};
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment