Skip to content
This repository has been archived by the owner on Jan 10, 2018. It is now read-only.

Commit

Permalink
Revert "WIP: Provide fractal state management (#269)"
Browse files Browse the repository at this point in the history
This reverts commit 32c0fe0.

This keeps this repo at version 2.x so we can keep the docs current and the monorepo will move forward with V4
  • Loading branch information
brandonroberts committed Apr 20, 2017
1 parent 108dc0e commit 5a9103a
Show file tree
Hide file tree
Showing 33 changed files with 369 additions and 3,481 deletions.
3 changes: 0 additions & 3 deletions .vscode/settings.json

This file was deleted.

8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ RxJS powered state management for Angular applications, inspired by Redux
on top of Angular. Core tenets:
- State is a single immutable data structure
- Actions describe state changes
- Pure functions called reducers take previous slices of state and the next action to compute the new state
- Pure functions called reducers take the previous state and the next action to compute the new state
- State accessed with the `Store`, an observable of state and an observer of actions

These core principles enable building components that can use the `OnPush` change detection strategy
Expand Down Expand Up @@ -57,7 +57,7 @@ export const INCREMENT = 'INCREMENT';
export const DECREMENT = 'DECREMENT';
export const RESET = 'RESET';

export function counterReducer(state: number = 0, action: Action): number {
export function counterReducer(state: number = 0, action: Action) {
switch (action.type) {
case INCREMENT:
return state + 1;
Expand All @@ -74,7 +74,7 @@ export function counterReducer(state: number = 0, action: Action): number {
}
```

In your app's main module, import those reducers and use the `StoreModule.forRoot(reducers)`
In your app's main module, import those reducers and use the `StoreModule.provideStore(reducers)`
function to provide them to Angular's injector:

```ts
Expand All @@ -85,7 +85,7 @@ import { counterReducer } from './counter';
@NgModule({
imports: [
BrowserModule,
StoreModule.forRoot({ counter: counterReducer })
StoreModule.provideStore({ counter: counterReducer })
]
})
export class AppModule {}
Expand Down
Empty file removed docs/action-reducers.md
Empty file.
Empty file removed docs/actions.md
Empty file.
Empty file removed docs/store-module.md
Empty file.
Empty file removed docs/store.md
Empty file.
14 changes: 6 additions & 8 deletions index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import * as __private_export__ from './src/private_export';

export { Action, ActionReducer, ActionReducerMap, ActionReducerFactory } from './src/models';
export { StoreModule } from './src/store_module';
export { Store } from './src/store';
export { combineReducers, compose } from './src/utils';
export { __private_export__ };

export * from './src/dispatcher';
export * from './src/ng2';
export * from './src/reducer';
export * from './src/state';
export * from './src/store';
export * from './src/utils';
71 changes: 31 additions & 40 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
"module": "./index.js",
"scripts": {
"karma": "karma start --single-run",
"test:unit": "node tests.js",
"test:unit:coverage": "nyc npm run test:unit",
"test:unit": "npm run karma",
"test:ngc": "ngc -p ./spec/ngc/tsconfig.ngc.json",
"test": "npm run test:unit && npm run test:ngc",
"clean:pre": "rimraf release",
Expand Down Expand Up @@ -36,50 +35,42 @@
},
"homepage": "https://github.com/ngrx/store#readme",
"peerDependencies": {
"@angular/core": "4.0.0-rc.1",
"@ngrx/core": "^1.1.0",
"rxjs": "^5.0.0"
"@angular/core": "^2.0.0",
"rxjs": "^5.0.0-beta.12",
"@ngrx/core": "^1.1.0"
},
"devDependencies": {
"@angular/common": "4.0.0-rc.1",
"@angular/compiler": "4.0.0-rc.1",
"@angular/compiler-cli": "4.0.0-rc.1",
"@angular/core": "4.0.0-rc.1",
"@angular/http": "4.0.0-rc.1",
"@angular/platform-browser": "4.0.0-rc.1",
"@angular/platform-browser-dynamic": "4.0.0-rc.1",
"@angular/platform-server": "4.0.0-rc.1",
"@angular/common": "^2.0.0",
"@angular/compiler": "^2.0.0",
"@angular/compiler-cli": "^0.6.0",
"@angular/core": "^2.0.0",
"@angular/platform-browser": "^2.0.0",
"@angular/platform-browser-dynamic": "^2.0.0",
"@angular/platform-server": "^2.0.0",
"@ngrx/core": "^1.2.0",
"@types/jasmine": "^2.5.42",
"@types/node": "^7.0.5",
"awesome-typescript-loader": "^3.0.4-rc.2",
"@types/jasmine": "^2.2.33",
"@types/node": "^6.0.38",
"awesome-typescript-loader": "^2.2.1",
"core-js": "^2.4.1",
"cpy-cli": "^1.0.1",
"istanbul-instrumenter-loader": "^2.0.0",
"jasmine": "^2.5.3",
"jasmine-marbles": "^0.0.2",
"nyc": "^10.1.2",
"istanbul-instrumenter-loader": "^0.2.0",
"jasmine": "^2.5.0",
"karma": "^1.2.0",
"karma-chrome-launcher": "^2.0.0",
"karma-coverage": "^1.1.1",
"karma-jasmine": "^1.0.2",
"karma-mocha-reporter": "^2.1.0",
"karma-sourcemap-loader": "^0.3.7",
"karma-webpack": "^1.8.0",
"rimraf": "^2.5.4",
"rollup": "^0.41.4",
"rxjs": "^5.1.0",
"ts-loader": "^2.0.0",
"ts-node": "^2.1.0",
"tslint": "^4.4.2",
"tslint-loader": "^3.3.0",
"typescript": "^2.1.6",
"rollup": "^0.34.13",
"rxjs": "^5.0.0-beta.11",
"ts-loader": "^0.8.2",
"tslint": "^3.15.1",
"tslint-loader": "^2.1.5",
"typescript": "^2.0.2",
"uglifyjs": "^2.4.10",
"webpack": "^2.2.1",
"zone.js": "^0.7.6"
},
"nyc": {
"extension": [
".ts"
],
"exclude": [
"spec/**/*.spec"
],
"include": [
"src/**/*.ts"
]
"webpack": "^2.1.0-beta.21",
"zone.js": "^0.6.17"
}
}
29 changes: 20 additions & 9 deletions spec/edge.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { Observable } from 'rxjs/Observable';
import { todos, todoCount } from './fixtures/edge_todos';
import { createInjector } from './helpers/injector';
import { Store, StoreModule } from '../';
import {ReflectiveInjector} from '@angular/core';
import {Observable} from 'rxjs/Observable';
import {todos, todoCount} from './fixtures/edge_todos';

import {Store, StoreModule, Dispatcher, State, Action, combineReducers} from '../';


interface TestAppSchema {
Expand All @@ -13,32 +14,41 @@ interface TestAppSchema {
interface Todo { }

interface TodoAppSchema {
todoCount: number;
visibilityFilter: string;
todos: Todo[];
}



describe('ngRx Store', () => {
describe('basic store actions', () => {
let store: Store<TodoAppSchema>;

describe('basic store actions', function() {

let injector: ReflectiveInjector;
let store: Store<TestAppSchema>;
let dispatcher: Dispatcher;

beforeEach(() => {
const injector = createInjector(StoreModule.forRoot<TodoAppSchema>({ todos, todoCount }));

injector = ReflectiveInjector.resolveAndCreate([
StoreModule.provideStore({ todos, todoCount }).providers
]);

store = injector.get(Store);
dispatcher = injector.get(Dispatcher);
});

it('should provide an Observable Store', () => {
expect(store).toBeDefined();
});

it('should handle re-entrancy', (done) => {

let todosNextCount = 0;
let todosCountNextCount = 0;

store.select('todos').subscribe((todos: any[]) => {
todosNextCount++;
todosNextCount++
store.dispatch({ type: 'SET_COUNT', payload: todos.length })
});

Expand All @@ -55,6 +65,7 @@ describe('ngRx Store', () => {
expect(todosCountNextCount).toBe(2);
done();
}, 10);

});
});
});
16 changes: 5 additions & 11 deletions spec/fixtures/todos.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
export interface TodoItem {
id: number;
completed: boolean;
text: string;
}

export const ADD_TODO = 'ADD_TODO';
export const COMPLETE_TODO = 'COMPLETE_TODO';
export const SET_VISIBILITY_FILTER = 'SET_VISIBILITY_FILTER';
Expand All @@ -26,7 +20,7 @@ export function visibilityFilter(state = VisibilityFilters.SHOW_ALL, {type, payl
}
};

export function todos(state: TodoItem[] = [], {type, payload}): TodoItem[] {
export function todos(state = [], {type, payload}) {
switch (type) {
case ADD_TODO:
return [
Expand All @@ -38,11 +32,11 @@ export function todos(state: TodoItem[] = [], {type, payload}): TodoItem[] {
}
];
case COMPLETE_ALL_TODOS:
return state.map(todo => ({ ...todo, completed: true }));
return state.map(todo => Object.assign({}, todo, {completed: true}));
case COMPLETE_TODO:
return state.map(todo =>
todo.id === payload.id ? { ...todo, completed: true } : todo
);
return state.map(todo => {
return todo.id === payload.id ? Object.assign({}, todo, {completed: true}) : todo;
});
default:
return state;
}
Expand Down
18 changes: 0 additions & 18 deletions spec/helpers/injector.ts

This file was deleted.

Loading

0 comments on commit 5a9103a

Please sign in to comment.