- Notifications
You must be signed in to change notification settings - Fork429
feat(Angular 5.0): update engine-etc for angular 5.0 & Domino#437
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
WIP - More updates to come
@MarkPieszak since this is working (great job by the way). Do we want to clean up that mast branch to be lean with this PR? I can wait till after to create one as well |
naveedahmed1 commentedOct 11, 2017
A clean up is much needed! |
Yes definitely 👍👍 If you want to take the branch for a spin and clean anything up just make commits right to this branch and we'll merge them all into master. |
naveedahmed1 commentedOct 12, 2017 • edited by MarkPieszak
Loading Uh oh!
There was an error while loading.Please reload this page.
edited by MarkPieszak
Uh oh!
There was an error while loading.Please reload this page.
@MarkPieszak can't we just replace the existing TransferHttp module with a simple interceptor like this? This way it seems more aligned with the theme of new HttpClientModule. import{Injectable,Inject,PLATFORM_ID}from'@angular/core';import{HttpEvent,HttpInterceptor,HttpHandler,HttpRequest,HttpResponse,HttpErrorResponse,HttpEventType}from'@angular/common/http';import{Observable}from'rxjs/Observable';import{TransferState}from'./../modules/transfer-state/transfer-state';import{isPlatformServer}from'@angular/common';import{ORIGIN_URL}from'./shared/constants/baseurl.constants';@Injectable()exportclassCustomHttpInterceptorimplementsHttpInterceptor{privateisServer=isPlatformServer(this.platformId);constructor( @Inject(PLATFORM_ID)privateplatformId,protectedtransferState:TransferState, @Inject(ORIGIN_URL)privatebaseUrl:string){}intercept(req:HttpRequest<any>,next:HttpHandler):Observable<HttpEvent<any>>{letmodifiedRequest:any;leturl:string;letisLocalRequest:boolean=!req.url.startsWith('http');if(isLocalRequest){url=(isLocalRequest ?this.baseUrl+req.url :req.url);// Skip cache check if the request method isn't GET.if(req.method=='GET'){constcachedResponse=this.getFromCache(url);if(cachedResponse){// A cached response exists. Serve it instead of forwarding// the request to the next handler.letmodifiedResponse=newHttpResponse<any>({headers:cachedResponse.headers,body:cachedResponse.body,status:cachedResponse.status,statusText:cachedResponse.statusText,url:cachedResponse.url});returnObservable.of(modifiedResponse);}}// Clone the request to add the new header.modifiedRequest=req.clone({headers:req.headers,url:url,body:req.body});}returnnext.handle(isLocalRequest ?modifiedRequest :req).do((event:HttpEvent<any>)=>{if(eventinstanceofHttpResponse){if(this.isServer){this.setCache(url,event);}}});}privatesetCache(key,data){returnthis.transferState.set(key,data);}privategetFromCache(key):HttpResponse<any>|null{returnthis.transferState.get(key);}} And in our |
We'll definitely be getting rid of the need to have TransferHttp locally, as we basically moved a similar one into Angular Core itself in 5.0. :) As for an interceptor to auto-append the current base_url, we definitely might as well add it! |
isaacrlevin commentedOct 20, 2017 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
@MarkPieszak this is probably safe to merge since your PR in Universal is merged as well. Only thing left pending is the transferhttp stuff right? Looking at this branch, I think all the features that are there are valuable, except maybe bootstrap. Maybe we just take Bootstrap and Translate out and leave Http, LazyLoading and Basic Component Thoughts? If that sounds good, I can take care of that real quick |
naveedahmed1 commentedOct 20, 2017
Below is the updated interceptor, which should work with Angular 5. |
Sometimes yes, but in this case since it's an InjectionToken from completely outside of itself, we need to do get it via the Injector, otherwise you get the quite vague error: |
@naveedahmed1 Good news, soon there will also be built in support for automatically adding relative path in Core :) Since we essentially do need them to make sure transfer stuff works. |
naveedahmed1 commentedOct 26, 2017
That would be awesome! Meanwhile I am not able to successfully implement ServerTransferStateModule from Angular 5, can you please also take a look at#448 |
I didn't have much time today, but ServerTransferStateModule seems to break server-renders for the time being, I'm going to merge this into Master, and hopefully one of us can figure out what's causing that to break, and we can eventually get that in there as well! :) |
naveedahmed1 commentedNov 2, 2017
@MarkPieszak can TransferHttpCacheModule (https://github.com/angular/universal/tree/master/modules/common ) be used in this case? It says:
I tried adding it, though it doesn't break the app. but the requests are still rendered twice once on server and once on client. |
…IO#437)* feat(5.0): update engine-etc for angular 5.0-rc1WIP - More updates to come* remove ng 4 references* update source maps for faster HMR builds* use aspnetcore-engine & misc updates and fixes* update to 5.0 officialClosesTrilonIO#434ClosesTrilonIO#435ClosesTrilonIO#430ClosesTrilonIO#424
…IO#437)* feat(5.0): update engine-etc for angular 5.0-rc1WIP - More updates to come* remove ng 4 references* update source maps for faster HMR builds* use aspnetcore-engine & misc updates and fixes* update to 5.0 officialClosesTrilonIO#434ClosesTrilonIO#435ClosesTrilonIO#430ClosesTrilonIO#424
…IO#437)* feat(5.0): update engine-etc for angular 5.0-rc1WIP - More updates to come* remove ng 4 references* update source maps for faster HMR builds* use aspnetcore-engine & misc updates and fixes* update to 5.0 officialClosesTrilonIO#434ClosesTrilonIO#435ClosesTrilonIO#430ClosesTrilonIO#424
…IO#437)* feat(5.0): update engine-etc for angular 5.0-rc1WIP - More updates to come* remove ng 4 references* update source maps for faster HMR builds* use aspnetcore-engine & misc updates and fixes* update to 5.0 officialClosesTrilonIO#434ClosesTrilonIO#435ClosesTrilonIO#430ClosesTrilonIO#424
…IO#437)* feat(5.0): update engine-etc for angular 5.0-rc1WIP - More updates to come* remove ng 4 references* update source maps for faster HMR builds* use aspnetcore-engine & misc updates and fixes* update to 5.0 officialClosesTrilonIO#434ClosesTrilonIO#435ClosesTrilonIO#430ClosesTrilonIO#424
…IO#437)* feat(5.0): update engine-etc for angular 5.0-rc1WIP - More updates to come* remove ng 4 references* update source maps for faster HMR builds* use aspnetcore-engine & misc updates and fixes* update to 5.0 officialClosesTrilonIO#434ClosesTrilonIO#435ClosesTrilonIO#430ClosesTrilonIO#424
…IO#437)* feat(5.0): update engine-etc for angular 5.0-rc1WIP - More updates to come* remove ng 4 references* update source maps for faster HMR builds* use aspnetcore-engine & misc updates and fixes* update to 5.0 officialClosesTrilonIO#434ClosesTrilonIO#435ClosesTrilonIO#430ClosesTrilonIO#424
…IO#437)* feat(5.0): update engine-etc for angular 5.0-rc1WIP - More updates to come* remove ng 4 references* update source maps for faster HMR builds* use aspnetcore-engine & misc updates and fixes* update to 5.0 officialClosesTrilonIO#434ClosesTrilonIO#435ClosesTrilonIO#430ClosesTrilonIO#424
Uh oh!
There was an error while loading.Please reload this page.
Fully-Functioning version updated to work with Angular 5.0-rc1.
Waiting until we merge updates to Aspnet-engine (in universal):angular/universal#825
Before officially merging into Master branch.
WIP - More updates to come
Closes#434
Closes#435
Closes#430
Closes#424
🎁 🍾