Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimistic action creator factory #2

Closed
the-dr-lazy opened this issue Jan 20, 2019 · 1 comment
Closed

Optimistic action creator factory #2

the-dr-lazy opened this issue Jan 20, 2019 · 1 comment
Labels
enhancement New feature or request

Comments

@the-dr-lazy
Copy link
Owner

the-dr-lazy commented Jan 20, 2019

action creator creation for optimistic flow is a good point to reduce boilerplate with a factory function.

Detailed Description

Each typical optimistic flow has 4 potential types of action:

  • next: starts an async flow
  • error: returns the error of the async flow rejection
  • complete: returns the successful result of the async flow
  • cancel: cause termination of the async flow

According to the nature of action types, all of these actions maybe contains payload and/or meta.

@the-dr-lazy the-dr-lazy added enhancement New feature or request help wanted Extra attention is needed good first issue Good for newcomers labels Jan 20, 2019
@the-dr-lazy the-dr-lazy changed the title Async action creator factory Optimistic action creator factory Jan 20, 2019
@the-dr-lazy
Copy link
Owner Author

the-dr-lazy commented Feb 4, 2019

current solution:

const fetchTodos = {
  next: createAction('[Todos] fetch'),
  error: createAction('[Todos] fetch error', resolve => (error: Error) => resolve(error)),
  complete: createAction('[Todos] fetch complete', resolve => (todos: Todo[]) => resolve(todos)),
  cancel: createAction('[Todos] fetch cancel')
}

I don't think a factory function would be handier than just a simple object.

@the-dr-lazy the-dr-lazy removed good first issue Good for newcomers help wanted Extra attention is needed labels Mar 30, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant