Coder Social home page Coder Social logo

platform's Introduction

platform's People

Contributors

angular-cli avatar bertrandk avatar chunghha avatar clbond avatar dagstuan avatar denkorolenko avatar drager avatar e-schultz avatar emrysmyrddin avatar genzodd avatar gitter-badger avatar ilyakrasnov avatar jonoward avatar kcopper8 avatar kuhnroyal avatar murraybauer avatar nexus-uw avatar pikachews avatar rajinder-yadav avatar rart avatar ratoaq2 avatar rmorrise avatar sbley avatar sergeykharchenko avatar sethdavenport avatar smithad15 avatar sumitarora avatar wbuchwalter avatar wtho avatar zhenyanghua avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

platform's Issues

ReactiveConnectDirective bad input, formGroup form not set in ConnectBase

This is a...

  • feature request
  • bug report
  • usage question

What toolchain are you using for transpilation/bundling?

  • @angular/cli
  • Custom @ngTools/webpack
  • Raw ngc
  • SystemJS
  • Rollup
  • Other

Environment

NodeJS Version: 10
Typescript Version: 3.2.4
Angular Version: 7.2.15
@angular-redux/store version: 10.0.0
@angular/cli version: 7.3.9
OS: Windows

Expected Behaviour:

class ReactiveConnectDirective extends ConnectBase {
@input() formGroup: any; // Must be @input('formGroup') form: any;
...
}
because:

Actual Behaviour:

connect-base does not have the property form set and cannot reset and initialize.

Stack Trace/Error Message:

core.js:15724 ERROR Error: Uncaught (in promise): TypeError: Cannot read property 'control' of undefined
TypeError: Cannot read property 'control' of undefined
at ReactiveConnectDirective.push../node_modules/@angular-redux/form/fesm5/angular-redux-form.js.ConnectBase.resetState (angular-redux-form.js:660)
at angular-redux-form.js:572

Lazy loading reducers

  • Migrate and verify solution from angular-redux/store#416
  • Add documentation including possible pitfalls (keys being overwritten, actions not having desired affect because reducer isn't loaded, middleware)

Angular schematics

Similar flux-based libs started providing schematics to reduce notoriously known "boilerplate". Is it planned feature within angular redux?

example-app: unable to start app & ci build fails

see Circle CI build: https://circleci.com/gh/angular-redux/example-app

also, when trying to run the example app locally (npm install && ng serve), it fails:

ERROR in /Users/sta/repo/angular-redux-platform/packages/example-app/node_modules/@angular-redux/store/lib/src/components/root-store.d.ts (13,35): Generic type 'Reducer' requires 1 type argument(s).
ERROR in /Users/sta/repo/angular-redux-platform/packages/example-app/node_modules/@angular-redux/store/lib/src/components/ng-redux.d.ts (25,44): Generic type 'Reducer' requires 1 type argument(s).
ERROR in /Users/sta/repo/angular-redux-platform/packages/example-app/node_modules/@angular-redux/store/lib/src/components/ng-redux.d.ts (42,82): Generic type 'Reducer' requires 1 type argument(s).
ERROR in /Users/sta/repo/angular-redux-platform/packages/example-app/node_modules/@angular-redux/store/lib/src/components/observable-store.d.ts (37,73): Generic type 'Reducer' requires 1 type argument(s).
ERROR in /Users/sta/repo/angular-redux-platform/packages/example-app/node_modules/@angular-redux/store/lib/src/components/fractal-reducer-map.d.ts (9,60): Generic type 'Reducer' requires 1 type argument(s).
ERROR in /Users/sta/repo/angular-redux-platform/packages/example-app/node_modules/@angular-redux/store/lib/src/components/fractal-reducer-map.d.ts (9,86): Generic type 'Reducer' requires 1 type argument(s).
ERROR in /Users/sta/repo/angular-redux-platform/packages/example-app/node_modules/@angular-redux/store/lib/src/components/fractal-reducer-map.d.ts (11,86): Generic type 'Reducer' requires 1 type argument(s).
ERROR in /Users/sta/repo/angular-redux-platform/packages/example-app/node_modules/@angular-redux/store/lib/src/components/fractal-reducer-map.d.ts (13,87): Generic type 'Reducer' requires 1 type argument(s).
ERROR in /Users/sta/repo/angular-redux-platform/packages/example-app/node_modules/@angular-redux/store/lib/src/decorators/helpers.d.ts (21,19): Generic type 'Reducer' requires 1 type argument(s).
ERROR in /Users/sta/repo/angular-redux-platform/packages/example-app/node_modules/@angular-redux/store/lib/src/components/ng-redux.d.ts (40,44): Generic type 'Reducer' requires 1 type argument(s).
ERROR in /Users/sta/repo/angular-redux-platform/packages/example-app/node_modules/@angular-redux/store/lib/src/components/root-store.d.ts (13,101): Type 'Middleware' is not generic.
ERROR in /Users/sta/repo/angular-redux-platform/packages/example-app/node_modules/@angular-redux/store/lib/src/components/root-store.d.ts (13,157): Generic type 'StoreEnhancer' requires 1 type argument(s).
ERROR in /Users/sta/repo/angular-redux-platform/packages/example-app/node_modules/@angular-redux/store/lib/src/components/root-store.d.ts (14,27): Generic type 'Store<S>' requires 1 type argument(s).
ERROR in /Users/sta/repo/angular-redux-platform/packages/example-app/node_modules/@angular-redux/store/lib/src/components/root-store.d.ts (17,35): Generic type 'Reducer' requires 1 type argument(s).
ERROR in /Users/sta/repo/angular-redux-platform/packages/example-app/node_modules/@angular-redux/store/lib/src/components/root-store.d.ts (20,80): Generic type 'Reducer' requires 1 type argument(s).
ERROR in /Users/sta/repo/angular-redux-platform/packages/example-app/node_modules/@angular-redux/form/dist/source/compose-reducers.d.ts (2,60): Generic type 'Reducer' requires 1 type argument(s).
ERROR in /Users/sta/repo/angular-redux-platform/packages/example-app/node_modules/@angular-redux/form/dist/source/compose-reducers.d.ts (2,92): Generic type 'Reducer' requires 1 type argument(s).
ERROR in /Users/sta/repo/angular-redux-platform/packages/example-app/node_modules/@angular-redux/form/dist/source/form-reducer.d.ts (3,194): Type 'Action' is not generic.
ERROR in Error: Metadata version mismatch for module /Users/sta/repo/angular-redux-platform/packages/example-app/node_modules/@angular-redux/store/lib/src/index.d.ts, found version 4, expected 3, resolving symbol AppModule in /Users/sta/repo/angular-redux-platform/packages/example-app/src/app/module.ts, resolving symbol AppModule in /Users/sta/repo/angular-redux-platform/packages/example-app/src/app/module.ts
    at syntaxError (/Users/sta/repo/angular-redux-platform/packages/example-app/node_modules/@angular/compiler/bundles/compiler.umd.js:1729:34)
    at simplifyInContext (/Users/sta/repo/angular-redux-platform/packages/example-app/node_modules/@angular/compiler/bundles/compiler.umd.js:24979:23)
    at StaticReflector.simplify (/Users/sta/repo/angular-redux-platform/packages/example-app/node_modules/@angular/compiler/bundles/compiler.umd.js:24991:13)
    at StaticReflector.annotations (/Users/sta/repo/angular-redux-platform/packages/example-app/node_modules/@angular/compiler/bundles/compiler.umd.js:24418:41)
    at _getNgModuleMetadata (/Users/sta/repo/angular-redux-platform/packages/example-app/node_modules/@angular/compiler-cli/src/ngtools_impl.js:138:31)
    at _extractLazyRoutesFromStaticModule (/Users/sta/repo/angular-redux-platform/packages/example-app/node_modules/@angular/compiler-cli/src/ngtools_impl.js:109:26)
    at Object.listLazyRoutesOfModule (/Users/sta/repo/angular-redux-platform/packages/example-app/node_modules/@angular/compiler-cli/src/ngtools_impl.js:53:22)
    at Function.NgTools_InternalApi_NG_2.listLazyRoutes (/Users/sta/repo/angular-redux-platform/packages/example-app/node_modules/@angular/compiler-cli/src/ngtools_api.js:91:39)
    at AotPlugin._getLazyRoutesFromNgtools (/Users/sta/repo/angular-redux-platform/packages/example-app/node_modules/@ngtools/webpack/src/plugin.js:240:66)
    at _donePromise.Promise.resolve.then.then.then.then.then (/Users/sta/repo/angular-redux-platform/packages/example-app/node_modules/@ngtools/webpack/src/plugin.js:493:24)
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:182:7)

My environment:

ng version
Your global Angular CLI version (6.0.7) is greater than your local
version (1.7.3). The local Angular CLI version is used.

To disable this warning use "ng config -g cli.warnings.versionMismatch false".

    _                      _                 ____ _     ___
   / \   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|
  / โ–ณ \ | '_ \ / _` | | | | |/ _` | '__|   | |   | |    | |
 / ___ \| | | | (_| | |_| | | (_| | |      | |___| |___ | |
/_/   \_\_| |_|\__, |\__,_|_|\__,_|_|       \____|_____|___|
               |___/
    
Angular CLI: 1.7.3
Node: 9.11.1
OS: darwin x64
Angular: 4.4.7
... common, compiler, compiler-cli, core, forms, http
... platform-browser, platform-browser-dynamic, router
... tsc-wrapped

@angular/cli: 1.7.3
@angular-devkit/build-optimizer: 0.3.2
@angular-devkit/core: 0.3.2
@angular-devkit/schematics: 0.3.2
@ngtools/json-schema: 1.2.0
@ngtools/webpack: 1.10.2
@schematics/angular: 0.3.2
@schematics/package-update: 0.3.2
typescript: 2.9.2
webpack: 3.11.0

Install behind corporate firwall

Hi,

We are using angular 7 in our company.

Our company has corporate firewall that is blocking github standard repository for npm install and instead using a private repository. Your library does not exist in that repository and I am not able to download from github repository. I also tried to download the source and package it myself but had so many errors circular dependencies etc. Any chance someone can prepackage latest version of all 3 packages (store, form and router), that way I will just upload them to private repository and it will be available for everyone including myself.

Thanks,
V

[Question] Angular 7 support

I am sorry to ask this kind of questions to Issues here.

@smithad15 could you answer what's being planned to support Angular 7 with these packages? ( I know the store v.9 works fine with Angular 7 except peer dependency warning on npm installation. ) If you could, it would be a great help for me to schedule our production updates to Angular 7.

Install Guidelines for angular-redux

I am trying to install angular-redux/store, angular-redux/routerm, and angular-redux/form in my Angular project ( "@angular/core": "^6.1.6", ).
My package.json show
"@angular-redux/form": "github:angular-redux/form", "@angular-redux/router": "github:angular-redux/router", "@angular-redux/store": "github:angular-redux/store",

redux version ( "redux": "^4.0.0",)
mentioned 3 entries but whenever I build the project It gives me an error 'cannot find module XXX'.

Is there any specific thing that I am missing or is there any version miss match?

Is this project still alive?

Dear maintainer,

I'm using this library on a corporate level and I was wondering if the project is still alive. It's been 3 months since the last commit. There's an interesting PR open since January (#72) and nothing seems to move here.

I have a piece of code I'd like to submit too, but I'm now considering to publish it under its own package, to ensure it will be accessible to the rest of the community.

Please, give us some news. If you don't feel to maintain it further, or don't have the time, consider transferring ownership to someone else.

Thanks for reading this ;-)

Global TSLint

Promote TSLint rules to the global scope and re-evaluate their contents

Upgrade Husky

Husky needs to be upgraded to v1+. This will require adjustment of the git hook config

Add contribution docs

Create guidelines around development practices and how to start contributing. Should be stored in a CONTRIBUTING.md file in the root of the project

Angular v8 support

This is a...

  • feature request
  • bug report
  • usage question

What toolchain are you using for transpilation/bundling?

  • @angular/cli
  • Custom @ngTools/webpack
  • Raw ngc
  • SystemJS
  • Rollup
  • Other

Environment

NodeJS Version: 10.16
Typescript Version: 3.4
Angular Version: 8
@angular-redux/store version: 10
@angular/cli version: (if applicable)
OS: Windows

Additional Notes:

Should we wait support of angular v8 from angular-redux or it's safe to use it as is with angular v8? Have you any plans to upgrade?

Module/Codesplitting Issue with @angular-redux/form

I am currently using @angular-redux/form 9.0.1 and when I tried to modularize my application using a reducer registry, I was unable to avoid this error: Typeerror: cannot read property 'getstate' of undefined at rootstore._this.getstate (root-store.js:40) coming from @angular-redux/form when loading any component that had a form with [connect] that was inside of a lazy-loaded module.

I was able to make a workaround in the following form by removing the [connect] altogether and mimicking the behavior like this:

this.subscriptionToForm = this.form.valueChanges.subscribe(value => {
    this.myService.dispatchPayload('@@angular-redux/form/FORM_CHANGED', { path: myFormPath, value });
});

This seems to work fine and resolves my current issue, but I wanted to mention the issue as you move forward with development on these packages.

Worried about future compatibility

There is evidence that this project is losing steam or at least is vulnerable to not being made compatible with future versions of Angular when they come out. The example app not being up to date is my biggest clue to this possible future. How can the public know that this repo will likely continue to be maintained? NgRx is looking like a better choice if one wants to move with updates to Angular.

Add support for Angular 8's change to esnext module code generation

This is a...

  • feature request
  • bug report
  • usage question

What toolchain are you using for transpilation/bundling?

  • @angular/cli
  • Custom @ngTools/webpack
  • Raw ngc
  • SystemJS
  • Rollup
  • Other

Environment

NodeJS Version: 11.9.0
Typescript Version: 3.4.5
Angular Version: 8.0.0
@angular-redux/store version: 10.0.0
@angular/cli version: (if applicable) 8.0.2
OS: darwin x64

Expected Behaviour:

The app should start without errors when the tsconfig.json's module option is set to esnext

Actual Behaviour:

The app crashes before startup with:

TypeError: Class constructor Observable cannot be invoked without 'new'
    at new ActionsObservable (ActionsObservable.js:30)
    at epicMiddleware (createEpicMiddleware.js:31)
    at redux.js:615
    at Array.map (<anonymous>)
    at redux.js:614
    at RootStore.configureStore (angular-redux-store.js:584)
    at new StoreModule (module.ts:41)
    at _createClass (core.js:26986)
    at _createProviderInstance (core.js:26940)
    at initNgModule (core.js:26846)

Stack Trace/Error Message:

TypeError: Class constructor Observable cannot be invoked without 'new'
    at new ActionsObservable (ActionsObservable.js:30)
    at epicMiddleware (createEpicMiddleware.js:31)
    at redux.js:615
    at Array.map (<anonymous>)
    at redux.js:614
    at RootStore.configureStore (angular-redux-store.js:584)
    at new StoreModule (module.ts:41)
    at _createClass (core.js:26986)
    at _createProviderInstance (core.js:26940)
    at initNgModule (core.js:26846)

Additional Notes:

Not sure if this issue belongs in https://github.com/redux-observable/redux-observable instead, let me know. Thanks!

redux-devtools-extension became a required dependency

This is a...

  • feature request
  • bug report
  • usage question

What toolchain are you using for transpilation/bundling?

  • @angular/cli
  • Custom @ngTools/webpack
  • Raw ngc
  • SystemJS
  • Rollup
  • Other

Environment

NodeJS Version: 8.9.4
Typescript Version: 3.2.4
Angular Version: 7.2.11
@angular-redux/store version: 10.0.0
@angular/cli version: 7.3.7
OS: Windows

Expected Behaviour:

redux-devtools-extension stays as a devDevendency

Actual Behaviour:

Due to the reference to redux-devtools-extension from the code - this dependency has become required.

Add standardized commit structure

Investigate and implement a standardized commit structure to allow for easier history browsing and automated tooling (i.e. changelog creation)

Reactive Forms broken in Version 10 of angular-redux/forms

This is a...

  • feature request
  • [x ] bug report
  • usage question

The "ReactiveConnectDirective" extends ConnectBase but does not set the protected field "form" anymore.

In Version 9 the Input property formGroup in "ReactiveConnect" is declared as:

@input('formGroup') form: any;

In Version 10 it is declared as:

@input() formGroup: any;

So ConnectBase.form is no longer set to the formGroup attributes value.

This breaks ConnectBase.resetState which is called from ConnectBase.ngAfterContentInit:

const formElement =
this.form.control === undefined ? this.form : this.form.control;

this.form is undefined and accessing control causes an error.

Unit Testing: MockNgRedux.getSelectorStub for @select with state => someFn(state)

This is a...

  • feature request
  • bug report
  • usage question

What toolchain are you using for transpilation/bundling?

  • @angular/cli
  • Custom @ngTools/webpack
  • Raw ngc
  • SystemJS
  • Rollup
  • Other

Environment

NodeJS Version: 8.11.2
Typescript Version: ~3.1.3
Angular Version: ^7.0.1
@angular-redux/store version: ^9.0.0
@angular/cli version: (if applicable)
OS:

Code Example

Here's my selector in my component class

@select(state => getItems(state)) items: Observable<Item[]>;

where getItems is a selector function that returns items from the state that match certain criteria

Unit Test

I'm attempting to set up a unit test for this selector, following the documentation here:
https://github.com/angular-redux/platform/blob/master/packages/store/articles/intro-tutorial.md#unit-testing-selections

My test:

const stub: Subject<Item[]> = MockNgRedux.getSelectorStub<AppState, Item[]>();
const expectedValue = // mocked object representing the state;

stub.next(expectedValue);
stub.complete();

componentUnderTest.items.subscribe(
  actualValues => expect(actualValues).toEqual(expectedValue),
  null,
  done
);

But I'm getting this error in my test:

Timeout - Async callback was not invoked within timeout specified by jasmine.DEFAULT_TIMEOUT_INTERVAL.

Questions:

Is there a way to test a selector which uses a selector function with a parameter of the entire state?
I'm using reselect for some of my selectors, but not all, and it's not working for either (see related issue: angular-redux/store#533)

Switch build process to ngPackagr

Unify all build tooling to leverage ngPackagr in order to unify with the greater ecosystem. This will also allow up to more easily support the angular package format.

Create a basic StackBlitz template

Having a basic StackBlitz setup for the library would be useful. This could be used as a template for issue reporting or just for the community at large.

[Form] StaticInjectorError(AppModule)[ConnectArray -> ConnectBase]

Error:

StaticInjectorError(AppModule)[ConnectArray -> ConnectBase]: 
  StaticInjectorError(Platform: core)[ConnectArray -> ConnectBase]: 
    NullInjectorError: No provider for ConnectBase!

Source:

  <ng-template connectArray
               let-index
               connectArrayOf="formTables">
    <div [ngModelGroup]="index">
      <input name="name"
             type="text"
             ngControl
             ngModel />
    </div>
  </ng-template>

The error occurred after I added the above code to map an array in redux to the form here. Started the project 2 days ago with latest versions of things. Angular 6, et. al. Please advise!

Related issues:

Environment:

    "@angular-redux/form": "^9.0.1",
    "@angular-redux/router": "^9.0.0",
    "@angular-redux/store": "^9.0.0",
    "@angular/animations": "^6.0.3",
    "@angular/common": "^6.0.3",
    "@angular/compiler": "^6.0.3",
    "@angular/core": "^6.0.3",
    "@angular/forms": "^6.0.3",
    "@angular/http": "^6.0.3",
    "@angular/platform-browser": "^6.0.3",
    "@angular/platform-browser-dynamic": "^6.0.3",
    "@angular/router": "^6.0.3",
    "core-js": "^2.5.4",
    "flux-standard-action": "^2.0.3",
    "ramda": "^0.25.0",
    "redux": "^4.0.0",
    "redux-localstorage": "^0.4.1",
    "redux-observable": "^1.0.0",
    "rxjs": "^6.0.0",
    "zone.js": "^0.8.26"

Thanks!

Unit Testing: Set Up Question

Posting this here, as well as in the old repo

This is a...

  • feature request
  • bug report
  • usage question

What toolchain are you using for transpilation/bundling?

  • @angular/cli
  • Custom @ngTools/webpack
  • Raw ngc
  • SystemJS
  • Rollup
  • Other

Environment

NodeJS Version: 8.11.2
Typescript Version: 2.7.2
Angular Version: 6.0.9
@angular-redux/store version: 9.0.0
@angular/cli version: (if applicable)

Description

I've read through the unit test examples, and believe that I have my set up correct. However, it seems like my mock instance is not being substituted for the real NgRedux that is injected.

Simplified Code

Component

  export class MyComponent implements OnInit {
    state: ApplicationState;
    constructor(private ngRedux: NgRedux<ApplicationState>) {}

    ngOnInit() {
       this.state = this.ngRedux.getState();
    }
  }

Unit Test

  // In the main describe...
  beforeEach(async(() => {
    TestBed.configureTestingModule({
      imports: [ NgReduxTestingModule ],
      declarations: [ MyComponent ],
      schemas: [ NO_ERRORS_SCHEMA ]
    })
    .compileComponents();
    MockNgRedux.reset();
   }));

  beforeEach(() => {
    fixture = TestBed.createComponent(MyComponent);
    component = fixture.componentInstance;
    fixture.detectChanges();
  });
  
  it('should set the initial state object', () => {
    const spy = spyOn(MockNgRedux.mockInstance, 'getState');
    expect(spy).toHaveBeenCalled();
  });

Error Message

When I run my tests with the code above, I get the message:
Expected spy getState to have been called.

Am I missing something in my set up?

lists are no refreshing by emit an event by output

I wrote an app with angular 7 and @angular-redux/store 9.
This app has two lists which contains hero objects. Each object has a boolean marker. The first list shows objects as 'true' marked. The other list shows objects with 'false' marked. If I press an hero object (marked as false) on the first list, the objects was marked as true, removed from the first list and showed on the second list.

I realize this with using a store, which change the flag. The first component receives the list (by select) and give it further to two list components by Input(). The click event used the Output-Parameter.

My Problem: No changes are visible.

[Stackblitz - Example][1]
[1]: https://stackblitz.com/edit/angular-twolists

Register epics in Application

Hi,

you wrote a Tutorial on how to register epics in a application but it seems not to work anymore.

I tried to reproduce the example and it starts with this error:
grafik

ActionObservable needs an argument T.

How can i use and register epics in my app.module? Especially with more then one epic.

export class AppModule {
  constructor(
    private ngRedux: NgRedux<IAppState>,
    private epics: SessionEpics,
  ) {
    const middleware = [createEpicMiddleware(this.epics.login)];
    ngRedux.configureStore(rootReducer, {}, middleware);
  }
}

Is this approach up-to-date in Version 9+?

Regards
rubiktubik

Passing rootreducer to the configureStore method fails compilation in Typescript

This is a...

  • feature request
  • [ ?] bug report
  • [ X] usage question

What toolchain are you using for transpilation/bundling?

  • @angular/cli
  • Custom @ngTools/webpack
  • Raw ngc
  • SystemJS
  • Rollup
  • Other

Environment

NodeJS Version: 8.11.3
Typescript Version: 2.9.3
Angular Version: 6.1.3
@angular-redux/store version: ^9.0.0
@angular/cli version: (if applicable): 6.1.2
OS: Windows

Expected Behavior:

I have the following types and reducers defined (abbreviated for clarity)


//-- Normalized model objects suitable for the store that use string keys --//
export interface NormalizedObjectsStr<T> {
    byId: LookupNum<T>;
    allIds: number[];
}

//-- Normalized model objects suitable for the store that use string keys --//
export interface NormalizedObjectsNum<T> {
    byId: { [id: number]: T };
    allIds: number[];
}

//-- Client side store of our data models --//
export interface ClientDataStore {
    categories: NormalizedObjectsNum<Category>
    attributes: NormalizedObjectsNum<Attribute>
}


// Definition of application state
export interface IAppState {
    entities?: ClientDataStore;
    classfnAppState?: IClassfnAppState;
}

//-- Entity reducers --//
const categoriesByIdReducer: Reducer<LookupNum<Category>, FluxStandardAction<Category | number>> = (state, action) => {
    switch (action.type) {
        default: { return state; }
    }
}

const allCategoryIdsReducer: Reducer<number[], FluxStandardAction<Category | number>> = (state, action) => {
    switch (action.type) {
        default: {
            return state;
        }
    }
}

const attributesByIdReducer: Reducer<LookupNum<Attribute>, FluxStandardAction<Category | number>> = (state, action) => {
    switch (action.type) {
        default: { return state; }
    }
}

const allAttributesIdsReducer: Reducer<number[], FluxStandardAction<Attribute | number>> = (state, action) => {
    switch (action.type) {
        default: {
            return state;
        }
    }
}


const categoriesReducer = combineReducers({
    byId: categoriesByIdReducer,
    allIds: allCategoryIdsReducer
});

const attributesReducer = combineReducers({

});

const entityReducer = combineReducers({
    categories: categoriesReducer,
    attributes: attributesReducer
});


//-- Create Root Reducer --//
export default combineReducers({
    entities: entityReducer,
    classfnAppState: classfnRootReducer
});

When I configure the store with this call:

import appRootReducer from './reducers';
store.configureStore(
            appRootReducer,
            INITIAL_STATE,
            [createLogger()],
            devTools.isEnabled() ? [devTools.enhancer()] : []);

It should compile and run.

Actual Behavior:

It won't compile with an error saying the reducer type is wrong. Notice it seems to have lost the type ClientDataStore for some reason. Because I'm combining multiple reducers across the state it seems to loose the intermediate interface definition.

Stack Trace/Error Message:

ERROR in src/app/classification/classification.component.ts(14,18): error TS2339: Property 'entities' does not exist on type 'IAppStateClassfn'.
src/app/store/store.module.ts(33,13): error TS2345: Argument of type 'Reducer<{ entities: { categories: any; attributes: any; }; classfnAppState: IClassfnAppState; }, ...' is not assignable to parameter of type 'Reducer<IAppState, AnyAction>'.
Types of parameters 'state' and 'state' are incompatible.
Type 'IAppState' is not assignable to type '{ entities: { categories: any; attributes: any; }; classfnAppState: IClassfnAppState; }'.
Property 'entities' is optional in type 'IAppState' but required in type '{ entities: { categories: any; attributes: any; }; classfnAppState: IClassfnAppState; }'.

Additional Notes:

(optional)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.