From 31c43b435343929c3b50f58c4c87710a3d78b74c Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Thu, 16 Nov 2017 12:06:49 -0500 Subject: [PATCH] ang2 notes WIP Signed-off-by: Bill Erickson --- NOTES.adoc | 76 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 NOTES.adoc diff --git a/NOTES.adoc b/NOTES.adoc new file mode 100644 index 000000000..1203e6134 --- /dev/null +++ b/NOTES.adoc @@ -0,0 +1,76 @@ += AngularJS -> Angular2+ Upgrade Notes == + +== State of AngularJS = + +AngularJS future is uncertain, but it won't disappear tomorrow: + +https://stackoverflow.com/questions/37037251/angularjs-1-x-support-lifecycle/37037365 + +We have a little breathing room. + +[quote] +-------------------------------------------------------- +Although my opinion isn't official, I would expect that the community of +developers will fork Angular 1.x and continue to maintain it for many +years. There are far too many large applications written on top of +Angular 1.x to just drop everything and dash off to Angular2. +-------------------------------------------------------- + +== Writing a new app the Angular2 way to experiment == + +* Install NodeJS v8 (v6 should also work). +[source,sh] +-------------------------------------------------------- +curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash - +sudo apt-get install -y nodejs +-------------------------------------------------------- + ** See also https://nodejs.org/en/download/package-manager/#debian-and-ubuntu-based-linux-distributions[NodeJS Install Docs] +* https://angular.io/tutorial +** Angular2+ is just AngularJS in Greek. Same concepts, new language. +* TypeScript is not required, but is almost universally assumed in + Angular, RXJS, Mozilla docs, stackoverflow, you-name-it documentation. +* NodeJS automates various developer tasks. + ** Handles boilerplate code generation. + ** TypeScript AOT (ahead-of-time) compiler + ** NodeJS is not required for serving files in real time. + ** Some dependencies we manually manage (grunt-uglify, karma, etc.) are + baked into 'ng build' + ** TypeScript and other dependency mangling can be precompiled to JS for + deployment to use with Apache, etc. + +[source,sh] +-------------------------------------------------------- +# --prod includes uglify, etc. +ng build [--dev|--prod] +-------------------------------------------------------- +* Observables are more common than Promise's (same idea, different terms). + ** http://reactivex.io/rxjs/ + ** http://reactivex.io/rxjs/class/es6/Observable.js~Observable.html + ** These have a slight benefit over promises of a consistent caller API + for atomic and streaming calls. + ** New-style promises no longer have a 'notify' operation! + ** https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise + ** Observables are the only way to have a stream. +* RouteResolvers only want a single value from an observable. Unclear why. + +* Use 'declare' to tell TypeScript about global, legacy/non-exported + variables, e.g. opensrf libs. +[source,sh] +-------------------------------------------------------- +// Global vars from opensrf.js +declare var OpenSRF, OSRF_TRANSPORT_TYPE_WS; +-------------------------------------------------------- + +* i18n! + ** use XLIFF file + ** Pre-compile language-specific builds for speedy fun-times + *** ng build --aot --i18nFile=src/locale/messages.fr.xlf --i18nFormat=xlf --locale=fr + *** Final build only contains french strings. + + +== ng-upgrade , etc. + +* Start with an angularjs hello-world and upgrade it. +* Try an angular2 hello-world and downgrade it. + + -- 2.11.0