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

Type issue with $select #541

Open
2 of 9 tasks
dweedon opened this issue Sep 4, 2018 · 1 comment
Open
2 of 9 tasks

Type issue with $select #541

dweedon opened this issue Sep 4, 2018 · 1 comment

Comments

@dweedon
Copy link

dweedon commented Sep 4, 2018

This is a...

  • feature request
  • bug report
  • usage question

What toolchain are you using for transpilation/bundling?

  • @angular/cli
  • Custom @ngTools/webpack
  • Raw ngc
  • SystemJS
  • Rollup
  • Other

Environment

NodeJS Version: 8
Typescript Version: 2.8
Angular Version: 6.0.3
@angular-redux/store version: ^9.0.0
OS: High Sierra

Expected Behaviour:

Given the following code:

const selector = (state: RootState): boolean => state.users.isSaving 
export class Users {
   ...

  @select$(
    selector,
    isSaving$ => isSaving$.pipe(map(isSaving => isSaving ? 'Saving…' : 'Save')),
  )
  saveButtonText$: Observable<string>;

saveButtonText$ should be an Observable<string>

Actual Behaviour:

It errors out when map(isSaving => isSaving ? 'Saving…' : 'Save') maps from Observable<boolean> to Observable<string>.

Additional Notes:

https://github.com/angular-redux/store/blob/master/src/decorators/select.ts#L62

off hand this should be something like

export function select$<T, A>(
  selector: Selector<any, T>,
  transformer: Transformer<T, A>,
  comparator?: Comparator
): PropertyDecorator {
  return decorate(selector, transformer, comparator);
}
@cholt0425
Copy link

I agree. I am fighting with this issue right now. One of the most common things to do to data is to transform it into another object that is more suitable to be used by the UI but the object you select out of the state has to be the same type as what you transform it to, when you use select$

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

2 participants