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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

馃殌[FEATURE]: Connect to actions stream #1632

Open
Carniatto opened this issue Jun 26, 2020 · 0 comments
Open

馃殌[FEATURE]: Connect to actions stream #1632

Carniatto opened this issue Jun 26, 2020 · 0 comments

Comments

@Carniatto
Copy link
Contributor

Relevant Package

This feature request is for @ngxs/store

Description

Provide an API that allows binding a stream of actions to NGXS.

Describe the problem you are trying to solve

Please describe the problem. If possible please substantiate it with the use cases you want to address.

Often a UI element provides a stream of events based on user input, for example, a search field would provide a change$ stream which could be denounced in the component.

Today the way to connect this stream of events to the state is by mapping each event emission of this observable to an imperative call to this.ngxsStore.dispatch. Breaking, therefore, the reactive nature of the code and also requiring the maintenance of the subscription on the component side.
Similarly, this would allow the implementer to decide which strategy to use to merge his actions in the stream, for example:

  • Load operation - exhaustMap
  • multiple update/delete operations - concatMap
  • Search operation - switchMap ( already possible with {cancelUncompleted}

Describe the solution you'd like

If you have a solution in mind, please describe it.

Provide an API that allows binding a stream of actions to the state avoiding the need to comparatively call this.ngxsStore.dispatch in a map operator. An initial proposition usage could be:

const actions$ = inputValueChange$.pipe(
  map(value => new Search(value))
)

this.ngxsStore.bindActions(inputValueChange$);

Initial discussion

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant