This file contains 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
return (<any>Object).assign({}, state, { | |
customer: action.payload | |
}); |
This file contains 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
// Application state is like a database. | |
// Currently our 'database' comprises of a single table | |
// that can be modified by a certain reducer. | |
// The sub-state's name in IAppState corresponds to | |
// reducer's name in reducers object. | |
export interface IAppState { | |
customerState: fromSubstates.ICustomerState | |
}; | |
// and we have only a single reducer here |
This file contains 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 developmentReducer: ActionReducer<IAppState> = compose(storeFreeze, combineReducers)(reducers); | |
const productionReducer: ActionReducer<IAppState> = combineReducers(reducers); | |
// our meta-reducer will take care of forwarding all actions | |
export function AppReducer(state: any, action: any) { | |
if (String('<%= BUILD_TYPE %>') === 'dev') { | |
return developmentReducer(state, action); | |
} else { | |
return productionReducer(state, action); | |
} |
This file contains 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 CustomerEffects { | |
@Effect() customerSelected$: Observable<Action> = this.actions$ | |
.ofType(CustomerActionTypes.SELECTED) | |
.map(action => { | |
let customer: ICustomer = _.cloneDeep(action.payload); | |
customer.active_debt = this.paymentService.activeDebt(customer.id); | |
customer.picture = this.imageService.imageUrl(customer.id); | |
return this.customerActions.customerInitialized(customer); |
This file contains 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 getCustomerState(state$: Observable<IAppState>): Observable<ICustomerState> { | |
return state$.select(state => state.customerState); | |
} | |
export const getCustomer: (obs: Observable<IAppState>) => Observable<ICustomer> = compose(fromSubstates.getCustomer, getCustomerState); |
This file contains 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
this.customerTable.on('select', (e: Event, dt: DataTables.DataTable, | |
type: string, indexes: number[]) => { | |
let row: INWCustomer = dt.rows(indexes[0]).data()['0']; | |
const customer = this.toLocalCustomer(row); | |
this.store.dispatch(this.customerActions.customerSelected(customer)); | |
}); |
This file contains 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 getCustomerObservable() { | |
this.customer = getCustomer(this.store); | |
} |
This file contains 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
this.store.select(appState => appState.customerState).subscribe(subState => { | |
const customerInstance = subState.customer; // not an observable but a concrete instance | |
}); |
This file contains 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
# open powershell and execute this file | |
# let the window open | |
# if the script won't start because of local execution policy restrictions you can use "Set-Execution-Policy Bypass" | |
$createdNew = $False; | |
$mutex = New-Object -TypeName System.Threading.Mutex($true, "MsWinZonesCacheCounterMutexA", [ref]$createdNew); |
This file contains 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
0x094f3723c13E9ee24de4AEb5b358FdD94D34315C |