This repository has been archived by the owner on Jan 10, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 311
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(Store): Enable fractal state management
- Loading branch information
1 parent
30544e9
commit 835bdb5
Showing
27 changed files
with
1,013 additions
and
596 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"typescript.tsdk": "./node_modules/typescript/lib" | ||
} |
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 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,10 @@ | ||
export * from './src/dispatcher'; | ||
export * from './src/ng2'; | ||
export * from './src/reducer'; | ||
export * from './src/state'; | ||
export * from './src/store'; | ||
export * from './src/utils'; | ||
export { ActionsObservable } from './src/actions-observable'; | ||
export { StoreConfig } from './src/config'; | ||
export { Dispatcher } from './src/dispatcher'; | ||
export { Action, ActionReducer, ActionReducerMap, ActionReducerFactory } from './src/models'; | ||
export { StoreModule } from './src/module'; | ||
export { ReducerObservable } from './src/reducer-observable'; | ||
export { StateObservable, reduceState } from './src/state-observable'; | ||
export { Store } from './src/store'; | ||
export { combineReducers } from './src/utils'; | ||
export { compose } from '@ngrx/core'; |
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 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 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 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { ReflectiveInjector, ModuleWithProviders } from '@angular/core'; | ||
|
||
|
||
export function createInjector({ ngModule, providers }: ModuleWithProviders): ReflectiveInjector { | ||
const injector = ReflectiveInjector.resolveAndCreate([ ...(providers || []), ngModule ]); | ||
|
||
injector.get(ngModule); | ||
|
||
return injector; | ||
} | ||
|
||
export function createChildInjector(parent: ReflectiveInjector, { ngModule, providers }: ModuleWithProviders): ReflectiveInjector { | ||
const injector = parent.resolveAndCreateChild([ ...(providers || []), ngModule ]); | ||
|
||
injector.get(ngModule); | ||
|
||
return injector; | ||
} |
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 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import 'rxjs/add/operator/take'; | ||
import { zip } from 'rxjs/observable/zip'; | ||
import { ReflectiveInjector } from '@angular/core'; | ||
import { createInjector, createChildInjector } from './helpers/injector'; | ||
import { StoreModule, Store } from '../'; | ||
|
||
|
||
describe('Nested Store Modules', () => { | ||
let store: Store<any>; | ||
|
||
beforeEach(() => { | ||
const parentReducers = { stateKey: () => 'root' }; | ||
const featureReducers = { stateKey: () => 'child' }; | ||
|
||
const rootInjector = createInjector(StoreModule.forRoot(parentReducers)); | ||
const featureInjector = createChildInjector(rootInjector, StoreModule.forFeature('inner', featureReducers)) | ||
|
||
store = rootInjector.get(Store); | ||
}); | ||
|
||
it('should nest the child module in the root store object', () => { | ||
store.take(1).subscribe(state => { | ||
expect(state).toEqual({ | ||
stateKey: 'root', | ||
inner: { | ||
stateKey: 'child' | ||
} | ||
}); | ||
}); | ||
}); | ||
}); | ||
|
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
Oops, something went wrong.