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

Add documentation for Effect with state dependency #560

Closed
MattiJarvinen opened this issue Nov 14, 2017 · 1 comment
Closed

Add documentation for Effect with state dependency #560

MattiJarvinen opened this issue Nov 14, 2017 · 1 comment

Comments

@MattiJarvinen
Copy link

I'm submitting a...


[ ] Regression (a behavior that used to work and stopped working in a new release)
[ ] Bug report  
[ ] Feature request
[x] Documentation issue or request

What is the current behavior?

Currently Effect documentation doesn't contain example for handling state dependent effects. Since I'm not really sure where this should even be put in 4.X documentation I just leave it here.

Expected behavior:

Adding this example would have value

...
import 'rxjs/add/operator/withLatestFrom';
...
class SomeEffects {
@Effect() refreshResultsWhenInBrowseMode$ = this.actions$
    .ofType(SearchActions.CHANGE_MODE, SearchActions.CLEAR_SEARCH)
    .withLatestFrom(this.state$)
    .filter(([action, state]) => state.search.mode === SearchMode.BROWSE)
    .map(([action, state]) => state.search.query)
    .map(query => this.searchActions.search(query));

constructor(private actions$: Actions,
            private state$: Store<AppState>) { }
}

Quoted from https:/ngrx/effects/issues/49#issuecomment-248994416

@timdeschryver
Copy link
Member

Closing this in favor of #1383.

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

No branches or pull requests

3 participants