File tree Expand file tree Collapse file tree 4 files changed +13
-22
lines changed Expand file tree Collapse file tree 4 files changed +13
-22
lines changed Original file line number Diff line number Diff line change 1
1
import { Component , OnInit } from '@angular/core' ;
2
2
import { Store , provideStore } from '@ngrx/store' ;
3
3
import { Observable } from 'rxjs/Rx' ;
4
- import { CurrentSearch } from './models/current-search.model' ;
5
4
import { ProximitySelector } from './components/proximity-selector.component' ;
6
5
import { SearchBox } from './components/search-box.component' ;
7
6
import { SearchReducer } from './reducers/search.reducer' ;
7
+ import { SearchQuery } from "./models/search-query.model" ;
8
8
9
9
const storeManager = provideStore ( { currentSearch : SearchReducer } ) ;
10
10
@@ -34,18 +34,18 @@ export class AppComponent implements OnInit {
34
34
35
35
title = 'One Source of Truth for Angular 2' ;
36
36
37
- private state : CurrentSearch ;
37
+ private state : SearchQuery ;
38
38
39
- private currentSearch : Observable < CurrentSearch > ;
39
+ private currentSearch : Observable < SearchQuery > ;
40
40
41
41
constructor (
42
- private store : Store < CurrentSearch >
42
+ private store : Store < SearchQuery >
43
43
) {
44
- this . currentSearch = this . store . select < CurrentSearch > ( 'currentSearch' ) ;
44
+ this . currentSearch = this . store . select < SearchQuery > ( 'currentSearch' ) ;
45
45
}
46
46
47
47
ngOnInit ( ) {
48
- this . currentSearch . subscribe ( ( state : CurrentSearch ) => {
48
+ this . currentSearch . subscribe ( ( state : SearchQuery ) => {
49
49
this . state = state ;
50
50
} ) ;
51
51
}
Original file line number Diff line number Diff line change 1
1
import { Component , Input } from '@angular/core' ;
2
2
import { Store } from '@ngrx/store' ;
3
- import { CurrentSearch } from '../models/current-search.model' ;
4
3
5
4
@Component ( {
6
5
selector : 'proximity-selector' ,
@@ -30,7 +29,7 @@ export class ProximitySelector {
30
29
} ;
31
30
32
31
@Input ( )
33
- store : Store < CurrentSearch > ;
32
+ store : Store < any > ;
34
33
35
34
active = false ;
36
35
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 1
1
import { ActionReducer , Action } from '@ngrx/store' ;
2
- import { CurrentSearch } from '../models/current-search.model' ;
3
2
import { SearchBox } from '../components/search-box.component' ;
4
3
import { ProximitySelector } from '../components/proximity-selector.component' ;
4
+ import { SearchQuery } from "../models/search-query.model" ;
5
5
6
- export const SearchReducer : ActionReducer < CurrentSearch > = ( state : CurrentSearch , action : Action ) => {
6
+ export const SearchReducer : ActionReducer < SearchQuery > = ( state : SearchQuery , action : Action ) => {
7
7
switch ( action . type ) {
8
8
case SearchBox . StoreEvents . text :
9
9
return Object . assign ( { } , state , {
@@ -18,12 +18,13 @@ export const SearchReducer: ActionReducer<CurrentSearch> = (state: CurrentSearch
18
18
} ) ;
19
19
case ProximitySelector . StoreEvents . radius :
20
20
return Object . assign ( { } , state , {
21
- radius : action . payload . radius
21
+ position : {
22
+ radius : action . payload . radius
23
+ }
22
24
} ) ;
23
25
case ProximitySelector . StoreEvents . off :
24
26
return Object . assign ( { } , state , {
25
- position : null ,
26
- radius : null
27
+ position : null
27
28
} ) ;
28
29
default :
29
30
return state ;
You can’t perform that action at this time.
0 commit comments