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 AccountReducer { | |
// with real DI inside | |
constructor (private usefulService: UsefulService) {} | |
createReducer() { | |
// handle specific action with the help of your injected service and return new states, this is the pure reducer function | |
return (state: AccountState, action: Action) => { | |
if(action.type === 'SomethingUseful' /* or better still action instanceof SomethingUsefulAction, but this makes for another post ;-)*/) { | |
return {...state, {useful: this.usefulService.something(action.payload)}} |
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 const ACCOUNT_REDUCER_TOKEN = new InjectionToken<ActionReducer<Map<string, Account>>>('Account state reducer') | |
export function accountReducerFactory(accountReducer: AccountReducer): ActionReducer<Map<string, Account>> { | |
// here you create a reducer function with access to other managed services | |
return accountReducer.createReducer() | |
} | |
@NgModule({ | |
imports: [ | |
StoreModule.forFeature('account', ACCOUNT_REDUCER_TOKEN) |
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
i18n.ActivityStatus={value, select, other {unknown}\ | |
COMPLETED {Completed}\ | |
DUE_TODAY {Due today}\ | |
OVERDUE {Overdue}\ | |
PENDING {Pending}\ | |
} | |
# Usage : {{'i18n.ActivityStatus' | translate:{value: activity.status} }} |
OlderNewer