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

selectParams not support optional parameters #21

Open
Pulsifi-ZiHao opened this issue Mar 7, 2023 · 0 comments
Open

selectParams not support optional parameters #21

Pulsifi-ZiHao opened this issue Mar 7, 2023 · 0 comments

Comments

@Pulsifi-ZiHao
Copy link

Pulsifi-ZiHao commented Mar 7, 2023

Description

when I try to upgrade from akita-ng-router-store, I have using selectParams which the parameter is an optional and there have no problem because when the parameter is undefined, selectParams still will emit the value, but elf-ng-router-store not supporting this. I want to suggest remove the filterNil operator from the selectParams method.

Proposed solution

 selectParams<T extends string>(
names?: string | string[]
): Observable<T | T[] | Params | null> {
  if (names === undefined) {
    return store.pipe(sliceState('params'));
  }

const _select = (p: string) =>
  store.pipe(
    sliceState<RouterState>('params'),
    pluck(p),
    filterNil() <--- remove this line
  );

if (Array.isArray(names)) {
  const sources = names.map(_select);
  return combineLatest(sources);
}

return _select(names).pipe(distinctUntilChanged());

}

Alternatives considered

no other alternatives

Do you want to create a pull request?

No

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