Skip to content

selectParams not support optional parameters #21

@Pulsifi-ZiHao

Description

@Pulsifi-ZiHao

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions