This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var numbers = [10, 15, 20, 22, 23]; | |
| numbers = numbers.filter(function(x) { return (x % 2) == 0 }); | |
| console.info(numbers); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @Injectable() export class SongEffects { | |
| @Effect() update$: Observable<Action> = this.action$ | |
| .ofType(songs.LOAD_SONGS) | |
| .switchMap(() => this.songService | |
| .getRates() | |
| .map(data => new SongsAreLoadedAction(data)) | |
| ); | |
| constructor( private currencyService: SongService, private action$: Actions ) {} | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| export function songReducer(state = initialState, action: Action) { | |
| switch(action.type) { | |
| case 'DELETE_SONG': const songId = action.payload; | |
| return state.filter(id => id !== songId); | |
| default: return state; | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { Number } from './../models/song'; | |
| import { Action } from '@ngrx/store'; | |
| export const LOADSONGS = '[Song] LoadAll'; | |
| export const SONGDELETED = '[Song] Delete'; | |
| export class LoadSongAction implements Action { | |
| type = LOAD_SONGS; | |
| } | |
| export class DeleteSongAction implements Action { | |
| type = SONG_DELETED; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { LoadSongsAction } from './actions/songs'; | |
| import { Store } from '@ngrx/store'; | |
| import * as fromRoot from './reducers'; // The convention is to define fromRoot as our namespace for reducers import { Observable } from 'rxjs/Observable'; | |
| @Component({ selector: 'app-root', | |
| templateUrl: './app.component.html', | |
| styleUrls: ['./app.component.css'], | |
| changeDetection: ChangeDetectionStrategy.OnPush | |
| }) |