-
Notifications
You must be signed in to change notification settings - Fork 406
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
fix(store): disable suppressing errors in selector #1015
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great idea. The internalSelectorOptions should not be exposed it was deliberately made internal. Maybe the internal selector options should inherit from the sharedSelectorOptions?
@markwhitfeld @NgModule({
imports: [
NgxsModule.forRoot([TasksState], {
developmentMode: true,
selectorOptions: { injectContainerState: false }
})
]
}) |
The |
Do not you think that this way you complicate the transition? I think we need the whole team to discuss this moment! because the decorator will be much harder to support and why people will need to have extra dependencies in their code. To upgrade to version 4, people can be asked to do so. @NgModule({
imports: [
NgxsModule.forRoot([TasksState], {
developmentMode: true,
selectorOptions: { injectContainerState: false }
})
]
}) If nothing works for them, it will be able for the 4th version to leave this injectContainerState flag to true as global settings. |
I have always thought of the transition using the decorators which come from the |
ngxs.config.ts export const NGXS_CONFIG = {
developmentMode: true,
selectorOptions: {
// use global options
injectContainerState: false
}
}; app.module.ts @NgModule({
imports: [
NgxsModule.forRoot([AppState], NGXS_CONFIG)
]
})
export class AppModule {} app.state.ts @State({
name: 'appState',
default: {
...
}
})
@SelectorsOptions({
// use options for local any selector in state
injectContainerState: true
})
export class AppState {
@Selector()
public static selectorA(state) {
return state;
}
@Selector()
public static selectorB(state) {
return state;
}
@Selector([])
@SelectorOptions({ injectContainerState: true })
public static selectorC(state) {
return state;
}
} |
@sinedied what do you think of this proposal? |
@splincode I think that we would need to rather have a |
My opinion on this is that a global setting for the whole app would be enough, a configuration per state seems overkill to me. We already went this way even before the v4 option is available, by making our own For people wanting to delay the migration, the easiest way for them to migrate would be one of this in my opinion:
I think compatibility selectors to either upgrade or downgrade with a distinct name is simpler and better than an option, as it's easier to track in the app during the migration (and easier to implement for you). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Going ahead with this PR. We will create a general purpose @SelectorOptions
which can be used to configure the options at class or method level.
PR Checklist
Please check if your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
What is the current behavior?
#843
What is the new behavior?
Does this PR introduce a breaking change?