-
-
Notifications
You must be signed in to change notification settings - Fork 240
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
feat(Modal): allow modal to be lazily loaded from a module on demand #772
feat(Modal): allow modal to be lazily loaded from a module on demand #772
Conversation
LGTM! |
@vakrilov good question - I will take a look and see (I was assuming so but will confirm!) |
Looks like there is an internal compiled ngmodule cache Angular uses under the hood: |
Those angular guys rock! |
Hey, @NathanWalker! Awesome PR! Can you attach a project with example usage, so we can integrate it in our e2e tests? |
@sis0k0 Thanks - the PR contains tests: https://github.com/NathanWalker/nativescript-angular/blob/lazy-load-then-open-modal/tests/app/tests/modal-dialog.ts#L145-L175 - this is the example usage however I can provide a completely separate repo with the same thing? |
Yes, that would be great! :) |
@sis0k0 I added yourself and @vakrilov to this test repo:
ItemComponent contains 2 buttons which demonstrate this: |
The failing test appears to be something related to unmet peer dep - lemme know if something you can reset on your end to rebuild - the PR was previously passing before merging in latest upstream master. |
Hey, @NathanWalker,
For example: you inject However, that's not such a big problem. We can add a catch here with some error message for that case. What do you think?
Now, when we're the AoT compiler, we're invoking the default Angular module loader SystemJsNgModuleLoader, which internally loads the module with System.import. The |
Hi @sis0k0 n/p.
The catch you mentioned in my opinion is not something I would handle in this plugin - Angular has it's own error condition handling which properly throws on this case.
Please consider this simplicity:
This can be used to help webpack create the bundle/chunk with the help of nativesript-dev-webpack. Then we (or I) simply document this fact to provide this value to the token in the very particular case of a user lazy loading a modal (with no routing config to the same module). Then at this point, it's just a developer and documentation thing. No hooks or error condition handling needed due to same reasons stated for 1. Thoughts? |
Hey Nathan, |
@sis0k0 Thank you so much, love your changes! 👍 👍 👍 |
Great! We'll fix the failing build ;) Meanwhile, can you drop the commit that ships the tgz? |
@sis0k0 I'll be back tomorrow afternoon and will take a look at that - should be able to rebase that outta there. |
* chore(deps): update to Angular 4.1.0 * chore(lint): update tslint to ^5.1.0 and codelyzer to ^3.0.1 * refactor: fix lint errors * fix: make update-app-ng-deps work with peerDeps
This should update all angular packages that the project depends on, such as @angular/animations and @angular/compiler-cli.
Update emulator api level to 23
* fix(renderer): set templateParent for newly create DetachedText nodes DetachedText is not inserted in the UI components tree, so we need to add it's parent manually. * fix(renderer): respect templateParent in parentNode() if one is set fixes #777, fixes #787 * test: add unit test for NgIfElse and NgIfThenElse * chore: target 'next' tag of tns-core-modules * fix(renderer): stop attaching comments to visual tree * refactor(renderer): create DetachedElements instead for comments and text nodes * refactor: move NgView, NgElement and similar to separate module
Change args for running nativescript-dev-appium
Update nativescirpt-dev-appium plugin to latest
Update --runtype=android23
…Async That method is internal for Angular and available only within the JiT compiler and we shouldn't expose it to user because it won't work within AoT compiled apps.
NativeScriptRouterModule SystemJsNgModuleLoader is injected in NSModuleFactoryLoader. That loader can be used without router, so we need to provide the systemjs token in the root NativeScriptModule instead.
we'll use e2e test for this functionality instead
@sis0k0 the commit that shipped the .tgz is now removed and latest master has been merged in. |
uitests android |
... aaand it is merged! 🎉 🎉 🎉 |
Excellent thanks for all the help! |
NgModule
to be lazily loaded on-demand (ie, via tap of a button without a route config) using the NSModuleFactoryLoaderComponent
to be opened in a modal even if it was lazily loaded on demandtemplate
usage throughout tests to use Angular 4ng-template
Assuming usage of the following in the module and/or a component's providers:
Example Usage in a
Component
:/cc @vakrilov