How do i execute a production build with ng2-redux and @select?

时间:2017-06-12 17:00:00

标签: angular redux angular-cli

I'm currently using ng2-redux to access global state in my application. I use DI to access that Observable. This all works fine with JIT, but when i execute an AOT buuild i get the following error:

ng build --environment=prod --target=production

ERROR in Error encountered resolving symbol values statically. Function calls are not supported. Consider replacing the function or lambda with a reference to an exported function (position 25:11 in the original .ts file), resolving symbol AdminComponent in /Users/jmurphy/projects/fish/tank/src/app/admin/admin.component.ts

I've been using the following pattern in all of my components to inject the Observables:

  @select((state: IAppState) => state.lens) public readonly remoteLens$: Observable<IRemoteObject<LensDTO>>;
  @select((state: IAppState) => state.admin) public readonly remoteAdmin$: Observable<IRemoteObject<AdminDTO>>;

What is the correct pattern to use to allow Type Safe access of the global state through out my application and bypass the build error?

1 个答案:

答案 0 :(得分:0)

您正在寻找:

export function selectBaseId(appstore) {
  return appStore.base.id;
}

class YourClass {
  // ...
  @select(selectBaseId) routeId$: Observable<number>;
}

或使用选择器:

export function selectBaseId(appstore) {
  return appStore.base.id;
}

class YourClass {
  // ...
  @select(['base', 'id']) routeId$: Observable<number>;
}

来自angular-redux问题:https://github.com/angular-redux/store/issues/236