Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 0 additions & 11 deletions docs/concepts/select.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,6 @@ In NGXS, there are two methods to select state, we can either call the `select`

## Select Decorator

📌 **Deprecation Notice**
The `@Select` decorator is deprecated, consider using the [Store Select Function](#store-select-function). It's deprecated due to the following reasons:
1) lack of type-safety
2) not compatible with server-side rendering because it uses a global `Store` instance, which might change between renders
3) not compatible with module federation
If you're using VSCode you can replace @Select usages with the following RegExp.
```
Search: @Select\((.*)\)\n(.*): Observable<(.*)>;$
Replace: $2 = this.store.select<$3>($1);
```

You can select slices of data from the store using the `@Select` decorator. It has a few
different ways to get your data out, whether passing the state class, a function, a different state class
or a memoized selector.
Expand Down
27 changes: 0 additions & 27 deletions packages/store/src/decorators/select/select.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,9 @@ import { createSelectObservable, createSelectorFn, PropertyType } from './symbol

/**
* Decorator for selecting a slice of state from the store.
* @deprecated
*/
export function Select<T>(rawSelector?: T, ...paths: string[]): PropertyDecorator {
return function(target, key): void {
if (typeof ngDevMode === 'undefined' || ngDevMode) {
warnSelectDeprecation();
}

const name: string = key.toString();
const selectorId = `__${name}__selector`;
const selector = createSelectorFn(name, rawSelector, paths);
Expand All @@ -30,25 +25,3 @@ export function Select<T>(rawSelector?: T, ...paths: string[]): PropertyDecorato
});
};
}

let selectDeprecatedHasBeenWarned = false;
function warnSelectDeprecation(): void {
if (selectDeprecatedHasBeenWarned) {
return;
}

selectDeprecatedHasBeenWarned = true;

console.warn(
`
The @Select decorator is deprecated due to the following reasons:
1) lack of type-safety (compared to 'store.select()')
2) not compatible with server-side rendering because it uses a global 'Store' instance, which might change between renders
3) not compatible with module federation
Consider replacing it the with store.select.
If you're using VSCode you can replace @Select usages with the following RegExp.
Search: @Select\((.*)\)\n(.*): Observable<(.*)>;$
Replace: $2 = this.store.select<$3>($1);
`
);
}