Skip to content

chore(Platform): Integrate example-app #12

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 12, 2017

Conversation

MikeRyanDev
Copy link
Member

@MikeRyanDev MikeRyanDev commented Apr 15, 2017

Migrates the example-app into the monorepo. This makes the example-app a viable target for complete ngrx integration tests. Right now the app mostly works. Things that block this PR:

  • @ngrx/router-store breaks badly when instrumented with the Redux Devtools Extension. This is because the router's state is not completely serializable cc @vsavkin
  • @angular/cli has a hard dependency on TypeScript 2.2 whereas we have a hard min dependency on TypeScript 2.3. Run yarn run clean:ts before trying to start the development server.
  • Both @ngrx/store and @ngrx/store-devtools now have mixed eager providers making it hard to debug undefined injector errors, see Eager providers and Injector.get() can cause errors angular/angular#15501
  • Example app unit tests use @ngrx/effects/testing which I do not plan to carry over for @ngrx/effects v4. These should instead be rewritten to use marble diagram tests cc @krjordan

* and recalculating new states. This enables powerful time-travel
* debugging.
*
* To use the debugger, install the Redux Devtools extension for either
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the instrumentOnlyWithExtension() functionality baked into instrument() now?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, there is now just one API for instrumentation regardless of strategy.

@MikeRyanDev MikeRyanDev force-pushed the chore/integrate-example-app branch 2 times, most recently from 277a201 to cedb2fb Compare April 18, 2017 02:07
@coveralls
Copy link

Coverage Status

Coverage remained the same at 89.791% when pulling cedb2fb on chore/integrate-example-app into 810b6b1 on master.

@vsavkin
Copy link
Contributor

vsavkin commented Apr 25, 2017

@MikeRyanDev the router state is not serializable because it has a cycle. Breaking the cycle would be a breaking change in the router and will have some negative implications on dev ergonomics. Is there a way to insert a function serializing the state?

@MikeRyanDev
Copy link
Member Author

@vsavkin Yes, we can write a custom serializer/parser for the dev tools that handles router state in a special way. The interface for these will have to be something like:

function serialize<T>(state: RouterState): T;

function revive<T>(state: T): RouterState;

where T is some shape that can be passed to JSON.stringify().

@vsavkin
Copy link
Contributor

vsavkin commented May 9, 2017

@MikeRyanDev I can write one if needed.

Quick question though: Why does it have to be serializable at all?

@Matmo10
Copy link

Matmo10 commented May 12, 2017

@MikeRyanDev Just FYI (you're probably already aware), deepFreezeing the router state also causes errors.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.05%) to 88.36% when pulling 246e261 on chore/integrate-example-app into 1f67cb3 on master.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.05%) to 88.36% when pulling bb4700b on chore/integrate-example-app into 1f67cb3 on master.

@@ -187,7 +187,6 @@ describe('ngRx Store', () => {

dispatcher.ngOnDestroy();

expect(storeSubscription.closed).toBe(true);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@MikeRyanDev this test was failing as the storeSubscription is no longer closed. It didn't show up until I upgraded RxJS. Is this a change in behavior?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I'm seeing the same thing. I think this behavior changed in newer versions of rxjs.

@brandonroberts brandonroberts force-pushed the chore/integrate-example-app branch from bb4700b to ab6ddfd Compare July 3, 2017 20:39
@coveralls
Copy link

Coverage Status

Coverage decreased (-0.05%) to 88.446% when pulling ab6ddfd on chore/integrate-example-app into b90df34 on master.

@brandonroberts brandonroberts changed the title [WIP] chore: integrate example-app chore(Platform): Integrate example-app Jul 3, 2017
@brandonroberts
Copy link
Member

@MikeRyanDev this branch is up-to-date and ready for another review

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.05%) to 88.446% when pulling 62b6c01 on chore/integrate-example-app into b90df34 on master.

* from feature modules. Effects can be loaded
* eagerly or lazily and will be started immediately.
*
* All Effects will only be instantiated regardless of
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"instantiated once"

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

actions$ = TestBed.get(Actions);
});

describe('search$', () => {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I hope you are prepared to start supporting marble testing questions... 😄

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😎

constructor(
private actions$: Actions,
private googleBooks: GoogleBooksService,
@Optional() @Inject(SEARCH_SCHEDULER) private scheduler: Scheduler,
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would maybe add a comment about why these are necessary for testability purposes.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

}

/**
* The compose function is one of our most handy tools. In basic terms, you give
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think many of these comments apply anymore. Maybe add a comment about what createSelector does?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we not need the comments for showing how the reducerFactory works?

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.05%) to 88.446% when pulling e8f3bd8 on chore/integrate-example-app into b90df34 on master.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.05%) to 88.446% when pulling a93862e on chore/integrate-example-app into b90df34 on master.

@brandonroberts brandonroberts force-pushed the chore/integrate-example-app branch from a93862e to 47a3d33 Compare July 12, 2017 02:08
@coveralls
Copy link

Coverage Status

Coverage decreased (-0.05%) to 88.528% when pulling 47a3d33 on chore/integrate-example-app into d176a11 on master.

@brandonroberts brandonroberts force-pushed the chore/integrate-example-app branch from 47a3d33 to 35be189 Compare July 12, 2017 19:21
@coveralls
Copy link

Coverage Status

Coverage remained the same at 88.426% when pulling 35be189 on chore/integrate-example-app into 68274c9 on master.

@brandonroberts brandonroberts force-pushed the chore/integrate-example-app branch from 35be189 to af886c5 Compare July 12, 2017 19:48
@coveralls
Copy link

Coverage Status

Coverage remained the same at 88.426% when pulling af886c5 on chore/integrate-example-app into 68274c9 on master.

@MikeRyanDev MikeRyanDev merged commit 22105c1 into master Jul 12, 2017
@MikeRyanDev MikeRyanDev deleted the chore/integrate-example-app branch July 12, 2017 20:26
@sharikovvladislav
Copy link
Contributor

Thank you!

@sharikovvladislav
Copy link
Contributor

Is it planned that example app does not work after merging this?

@sharikovvladislav
Copy link
Contributor

sharikovvladislav commented Jul 12, 2017

I get this on ng serve right after yarn install:

WARNING in ./modules/store-devtools/src/devtools.ts
122:523-542 "export 'StoreDevtoolsConfig' was not found in './config'

WARNING in ./modules/store-devtools/src/devtools.ts
122:562-581 "export 'StoreDevtoolsConfig' was not found in './config'

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 47:10 in the original .ts file), resolving symbol compose in /Users/svlad/dev/platform/modules/store/src/utils.ts, resolving symbol developmentReducerFactory in /Users/svlad/dev/platform/example-app/app/reducers/index.ts, resolving symbol AppModule in /Users/svlad/dev/platform/example-app/app/app.module.ts, resolving symbol AppModule in /Users/svlad/dev/platform/example-app/app/app.module.ts, resolving symbol AppModule in /Users/svlad/dev/platform/example-app/app/app.module.ts

macOS 10.12.5

@brandonroberts
Copy link
Member

@sharikovvladislav it's a known issue with the CLI. If you save any file and let it recompile it will complete successfully

@sharikovvladislav
Copy link
Contributor

sharikovvladislav commented Jul 12, 2017

@brandonroberts
What about warnings? Do they matter?

Ok, if I recompile everything is ok. Lets assume it is not problem. Now I don't have error. But when I open localhost:4200 I have this:

core.es5.js:1020 ERROR Error: Uncaught (in promise): Error: Cannot find module 'app/books/books.module'.
Error: Cannot find module 'app/books/books.module'.
    at webpackEmptyContext (example-app async:2)
    at SystemJsNgModuleLoader.webpackJsonp.../../../core/@angular/core.es5.js.SystemJsNgModuleLoader.loadAndCompile (core.es5.js:5644)
    at SystemJsNgModuleLoader.webpackJsonp.../../../core/@angular/core.es5.js.SystemJsNgModuleLoader.load (core.es5.js:5632)
    at RouterConfigLoader.webpackJsonp.../../../router/@angular/router.es5.js.RouterConfigLoader.loadModuleFactory (router.es5.js:3417)
    at RouterConfigLoader.webpackJsonp.../../../router/@angular/router.es5.js.RouterConfigLoader.load (router.es5.js:3401)
    at MergeMapSubscriber.project (router.es5.js:1569)
    at MergeMapSubscriber.webpackJsonp.../../../../rxjs/operator/mergeMap.js.MergeMapSubscriber._tryNext (mergeMap.js:120)
    at MergeMapSubscriber.webpackJsonp.../../../../rxjs/operator/mergeMap.js.MergeMapSubscriber._next (mergeMap.js:110)
    at MergeMapSubscriber.webpackJsonp.../../../../rxjs/Subscriber.js.Subscriber.next (Subscriber.js:89)
    at ScalarObservable.webpackJsonp.../../../../rxjs/observable/ScalarObservable.js.ScalarObservable._subscribe (ScalarObservable.js:49)
    at webpackEmptyContext (example-app async:2)
    at SystemJsNgModuleLoader.webpackJsonp.../../../core/@angular/core.es5.js.SystemJsNgModuleLoader.loadAndCompile (core.es5.js:5644)
    at SystemJsNgModuleLoader.webpackJsonp.../../../core/@angular/core.es5.js.SystemJsNgModuleLoader.load (core.es5.js:5632)
    at RouterConfigLoader.webpackJsonp.../../../router/@angular/router.es5.js.RouterConfigLoader.loadModuleFactory (router.es5.js:3417)
    at RouterConfigLoader.webpackJsonp.../../../router/@angular/router.es5.js.RouterConfigLoader.load (router.es5.js:3401)
    at MergeMapSubscriber.project (router.es5.js:1569)
    at MergeMapSubscriber.webpackJsonp.../../../../rxjs/operator/mergeMap.js.MergeMapSubscriber._tryNext (mergeMap.js:120)
    at MergeMapSubscriber.webpackJsonp.../../../../rxjs/operator/mergeMap.js.MergeMapSubscriber._next (mergeMap.js:110)
    at MergeMapSubscriber.webpackJsonp.../../../../rxjs/Subscriber.js.Subscriber.next (Subscriber.js:89)
    at ScalarObservable.webpackJsonp.../../../../rxjs/observable/ScalarObservable.js.ScalarObservable._subscribe (ScalarObservable.js:49)
    at resolvePromise (zone.js:770)
    at resolvePromise (zone.js:741)
    at zone.js:818
    at ZoneDelegate.webpackJsonp.../../../../zone.js/dist/zone.js.ZoneDelegate.invokeTask (zone.js:424)
    at Object.onInvokeTask (core.es5.js:3881)
    at ZoneDelegate.webpackJsonp.../../../../zone.js/dist/zone.js.ZoneDelegate.invokeTask (zone.js:423)
    at Zone.webpackJsonp.../../../../zone.js/dist/zone.js.Zone.runTask (zone.js:191)
    at drainMicroTaskQueue (zone.js:584)
    at <anonymous>

Was that planned? =)

@brandonroberts
Copy link
Member

brandonroberts commented Jul 12, 2017

@sharikovvladislav no 😄 I saw that issue before, but not consistently. Try changing app/books/books.module to ./books/books.module in the routes.ts file and save and see if that works

@sharikovvladislav
Copy link
Contributor

@brandonroberts That does not work. Same result. A bit another message (because of path changed): Cannot find module './books/books.module'.

@brandonroberts
Copy link
Member

Ok. I'll take a look into it

@sharikovvladislav
Copy link
Contributor

sharikovvladislav commented Jul 12, 2017

Note that I run ng serve in root of platform repo. Can I help with something? Do you need more info?

@sharikovvladislav
Copy link
Contributor

sharikovvladislav commented Jul 14, 2017

@brandonroberts I don't know how it is possible, but now everything works fine. I checked in Chrome and Chrome Canary

Some time ago I wanted to make a PR to fix e2e tests. I fixed root problem (that was in ngrx/example-app repo) but now angular application can not be detected in test run.

May be this is related to:

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 47:10 in the original .ts file), resolving symbol compose in /Users/svlad/dev/platform/modules/store/src/utils.ts, resolving symbol developmentReducerFactory in /Users/svlad/dev/platform/example-app/app/reducers/index.ts, resolving symbol AppModule in /Users/svlad/dev/platform/example-app/app/app.module.ts, resolving symbol AppModule in /Users/svlad/dev/platform/example-app/app/app.module.ts, resolving symbol AppModule in /Users/svlad/dev/platform/example-app/app/app.module.ts

What do you think? Do you know issue number in angular-cli?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants