Skip to content
This repository was archived by the owner on Jul 8, 2021. It is now read-only.

Commit 6b8ea51

Browse files
author
Austin McDaniel
committed
select imperative naming
1 parent 7daa305 commit 6b8ea51

File tree

3 files changed

+7
-3
lines changed

3 files changed

+7
-3
lines changed

CHANGELOG.md

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# Master
2+
- Feature: Implied select name from property name
3+
14
# 1.2.0 - 1/3/17
25
- Feature: Select decorator
36

README.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,8 @@ We didn't leave out selectors, there is a `Select` decorator that accepts a (dee
148148
```javascript
149149
@Component({ ... })
150150
export class MyComponent {
151-
@Select('my.prop.color') color$: Observable<string>;
151+
@Select('my.prop.color') color$: Observable<string>; // deeply nested props
152+
@Select() color: Observable<string>; // implied by name
152153
}
153154
```
154155

src/index.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,11 @@ export function ofAction < T extends Action > (...allowedTypes: any[]) {
6666
let store;
6767
export const ngrxSelect = (s => store = s);
6868

69-
export function Select(path: string): any {
69+
export function Select(path?: string): any {
7070
return function (target: any, name: string, descriptor: TypedPropertyDescriptor <any>): void {
7171
if (delete target[name]) {
7272
Object.defineProperty(target, name, {
73-
get: () => store.select(state => getValue(state, path)),
73+
get: () => store.select(state => getValue(state, path || name)),
7474
enumerable: true,
7575
configurable: true
7676
});

0 commit comments

Comments
 (0)