Skip to content
This repository has been archived by the owner on Sep 25, 2020. It is now read-only.

Latest commit

 

History

History
34 lines (24 loc) · 872 Bytes

create-an-actions-provider.md

File metadata and controls

34 lines (24 loc) · 872 Bytes

Create an actions provider

Of course you can also create a provider to fire your Redux actions. Here's an example using @ReduxActionContext and @ReduxAction:

Example

import { Injectable } from '@angular/core';
import { ReduxAction, ReduxActionContext } from '@harmowatch/ngx-redux-core';

@Injectable()
@ReduxActionContext({prefix: 'TodoActions://'})
export class TodoActions {

  @ReduxAction()
  add(label: string): TodoListItem {
    return label; // your return value is the payload
  }

}

Now @harmowatch/ngx-redux-core will dispatch the following action, every time the add method was called:

{
  "type": "TodoActions://add",
  "payload": "SampleTodo"
}