Skip to content

Instantly share code, notes, and snippets.

@mfp22
Last active March 23, 2021 09:03
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mfp22/04554a972dab83cfca7535ef857c810d to your computer and use it in GitHub Desktop.
Save mfp22/04554a972dab83cfca7535ef857c810d to your computer and use it in GitHub Desktop.
requireUsers$ = this.userSelectors.needUsers$.pipe(
filter(needUsers => needUsers),
tap(() => this.store.dispatch({type: 'GET_USERS'})),
switchMap(() => this.getUsers()),
tap(users => this.store.dispatch({type: 'RECEIVE_USERS', users})),
share(),
);
users$ = using(
() => this.requireUsers$.subscribe(),
() => this.userSelectors.users$,
);
requireUsersExtraData$ = this.users$.pipe(
withLatestFrom(this.userSelectors.needUsersExtraData$),
filter(([users, needData]) => Boolean(users.length) && needData),
tap(() => this.store.dispatch({type: 'GET_USERS_EXTRA_DATA'})),
switchMap(() => this.getUsers()),
tap(users => this.store.dispatch({
type: 'RECEIVE_USERS_EXTRA_DATA',
users
})),
share(),
);
usersExtraData$ = using(
() => this.requireUsersExtraData$.subscribe(),
() => this.userSelectors.usersExtraData$,
);
@delexi
Copy link

delexi commented May 10, 2018

I assume line 17 is supposed to call this.getExtraData() or something along those lines?

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