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
| private appendScript(host: HTMLElement, data: string, index: number) { | |
| this.ngZone.runOutsideAngular(() => { | |
| const script = document.createElement('script'); | |
| script.type = 'text/javascript'; | |
| script.charset = 'utf-8'; | |
| script.id = this.vrScriptPrefix + index; | |
| script.defer = true; | |
| script.async = true; | |
| script.text = data; | |
| host.appendChild(script); |
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
| interface IVrModule { | |
| id: string; | |
| name: string; | |
| type: VrModuleType; | |
| markup: string; | |
| scripts?: string[]; | |
| } |
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
| const vrModuleReducer: ActionReducer<IVrModule[]> = (state: IVrModule[] = | |
| initialState, action: Action) => { | |
| switch (action.type) { | |
| case VR_MODULE_REMOVED: | |
| return _.filter(state, (mod) => mod.id === action.payload.id); | |
| case VR_MODULE_ADDED: | |
| return _.concat(state, action.payload); | |
| 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
| /** | |
| * Initialize subscriptions and get app state via @ngrx (Redux implementation for Angular2) | |
| */ | |
| public ngOnInit() { | |
| [....snip...] | |
| this.availableModules = <Observable<IVrModule[]>> this.store.select('vrModule'); | |
| [....snip...] | |
| } |
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
| const appStore = provideStore( | |
| { | |
| vrModule: vrModuleReducer | |
| }, | |
| { | |
| vrModule: this.vrModule | |
| } | |
| ); |
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 interface ICustomerActions { | |
| INIT: string; | |
| INIT_FAILED: string; | |
| INITIALIZED: string; | |
| SELECTED: string; | |
| CHANGED: string; | |
| SAVED: string; | |
| DELETED: string; | |
| } |
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 class InitCustomerAction implements Action { | |
| type = CustomerActionTypes.INIT; | |
| payload: ICustomer = null; | |
| } | |
| export class InitializedCustomerAction implements Action { | |
| type = CustomerActionTypes.INITIALIZED; | |
| constructor(public payload: ICustomer) { } | |
| } |
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 type CustomerAction | |
| = InitCustomerAction | |
| | InitializedCustomerAction | |
| | InitFailedCustomerAction | |
| | CustomerSelectedAction | |
| | CustomerChangedAction | |
| | CustomerDeletedAction | |
| | CustomerSavedAction; |
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 { Injectable } from '@angular/core'; | |
| import { Action } from '@ngrx/store'; | |
| import { ICustomer } from '../../interfaces'; | |
| import * as customer from '../customer.actions'; | |
| @Injectable() | |
| export class CustomerActions { | |
| public customerInit() { | |
| return new customer.InitCustomerAction(); | |
| } |
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 { ICustomerState, initialCustomerState } from '../states/sub-states'; | |
| import { CustomerAction, CustomerActionTypes } from '../actions'; | |
| export function customerReducer( | |
| state: ICustomerState = initialCustomerState, | |
| action: CustomerAction | |
| ): ICustomerState { | |
| switch (action.type) { | |
| case CustomerActionTypes.INITIALIZED: | |
| return (<any>Object).assign({}, state, { |