From: Bill Erickson <berickxx@gmail.com> Date: Wed, 17 Apr 2019 21:47:39 +0000 (-0400) Subject: ts notes X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=94f67f4483a35bdb2ea3b98a3a94212fac64ee97;p=working%2Frandom.git ts notes Signed-off-by: Bill Erickson <berickxx@gmail.com> --- diff --git a/tsfun.adoc b/tsfun.adoc index 5bcfcf2a6..5a673c5af 100644 --- a/tsfun.adoc +++ b/tsfun.adoc @@ -35,12 +35,17 @@ set msg(s: string) { this._msg = s; - this.doImportStuff(); + this.doImportantStuff(); } ------------------------------------------------------------------------- == Setters with Angular Component Inputs +[source,html] +------------------------------------------------------------------------- +<my-component [msg]="localMsgVar" ...></my-component> +------------------------------------------------------------------------- + [source,javascript] ------------------------------------------------------------------------- @Input() set msg(s: string) { @@ -49,7 +54,7 @@ set msg(s: string) { console.debug('Parent component passed new value for msg', s); - this.doImportStuff(); + this.doImportantStuff(); } ------------------------------------------------------------------------- @@ -72,6 +77,26 @@ modifyCar(): Promise<CarStuff> { } ------------------------------------------------------------------------- +== Nesty Version + +[source,javascript] +------------------------------------------------------------------------- +modifyCar(): Promise<CarStuff> { + + return this.loadCar().then((car: Car) => { + + this.colorDialog.open(car).then((color: string) => { + + this.applyColor(color).then( + + (cost: number) => this.addCost(cost) + ) + }); + }); +} +------------------------------------------------------------------------- + + == Drum Roll Please ð¥ ... == Converted to Async Functions diff --git a/tsfun.html b/tsfun.html index 7cf684b6a..44ea39375 100644 --- a/tsfun.html +++ b/tsfun.html @@ -3878,7 +3878,7 @@ http://www.gnu.org/software/src-highlite --> <span style="font-weight: bold"><span style="color: #0000FF">this</span></span><span style="color: #990000">.</span>_msg <span style="color: #990000">=</span> s<span style="color: #990000">;</span> - <span style="font-weight: bold"><span style="color: #0000FF">this</span></span><span style="color: #990000">.</span><span style="font-weight: bold"><span style="color: #000000">doImportStuff</span></span><span style="color: #990000">();</span> + <span style="font-weight: bold"><span style="color: #0000FF">this</span></span><span style="color: #990000">.</span><span style="font-weight: bold"><span style="color: #000000">doImportantStuff</span></span><span style="color: #990000">();</span> <span style="color: #FF0000">}</span></tt></pre></div></div> </div> </div> @@ -3890,13 +3890,19 @@ http://www.gnu.org/software/src-highlite --> by Lorenzo Bettini http://www.lorenzobettini.it http://www.gnu.org/software/src-highlite --> +<pre><tt><span style="font-weight: bold"><span style="color: #0000FF"><my-component</span></span> <span style="color: #009900">[msg]</span><span style="color: #990000">=</span><span style="color: #FF0000">"localMsgVar"</span> ...<span style="font-weight: bold"><span style="color: #0000FF">></my-component></span></span></tt></pre></div></div> +<div class="listingblock"> +<div class="content"><!-- Generator: GNU source-highlight +by Lorenzo Bettini +http://www.lorenzobettini.it +http://www.gnu.org/software/src-highlite --> <pre><tt>@<span style="font-weight: bold"><span style="color: #000000">Input</span></span><span style="color: #990000">()</span> set <span style="font-weight: bold"><span style="color: #000000">msg</span></span><span style="color: #990000">(</span>s<span style="color: #990000">:</span> string<span style="color: #990000">)</span> <span style="color: #FF0000">{</span> <span style="font-weight: bold"><span style="color: #0000FF">this</span></span><span style="color: #990000">.</span>_msg <span style="color: #990000">=</span> s<span style="color: #990000">;</span> console<span style="color: #990000">.</span><span style="font-weight: bold"><span style="color: #000000">debug</span></span><span style="color: #990000">(</span><span style="color: #FF0000">'Parent component passed new value for msg'</span><span style="color: #990000">,</span> s<span style="color: #990000">);</span> - <span style="font-weight: bold"><span style="color: #0000FF">this</span></span><span style="color: #990000">.</span><span style="font-weight: bold"><span style="color: #000000">doImportStuff</span></span><span style="color: #990000">();</span> + <span style="font-weight: bold"><span style="color: #0000FF">this</span></span><span style="color: #990000">.</span><span style="font-weight: bold"><span style="color: #000000">doImportantStuff</span></span><span style="color: #990000">();</span> <span style="color: #FF0000">}</span></tt></pre></div></div> </div> </div> @@ -3926,6 +3932,29 @@ http://www.gnu.org/software/src-highlite --> </div> </div> <div class="sect1 slide"> +<h1 id="_nesty_version">Nesty Version</h1> +<div class="sectionbody" style="max-width:45em"> +<div class="listingblock"> +<div class="content"><!-- Generator: GNU source-highlight +by Lorenzo Bettini +http://www.lorenzobettini.it +http://www.gnu.org/software/src-highlite --> +<pre><tt><span style="font-weight: bold"><span style="color: #000000">modifyCar</span></span><span style="color: #990000">():</span> Promise<span style="color: #990000"><</span>CarStuff<span style="color: #990000">></span> <span style="color: #FF0000">{</span> + + <span style="font-weight: bold"><span style="color: #0000FF">return</span></span> <span style="font-weight: bold"><span style="color: #0000FF">this</span></span><span style="color: #990000">.</span><span style="font-weight: bold"><span style="color: #000000">loadCar</span></span><span style="color: #990000">().</span><span style="font-weight: bold"><span style="color: #000000">then</span></span><span style="color: #990000">((</span>car<span style="color: #990000">:</span> Car<span style="color: #990000">)</span> <span style="color: #990000">=></span> <span style="color: #FF0000">{</span> + + <span style="font-weight: bold"><span style="color: #0000FF">this</span></span><span style="color: #990000">.</span>colorDialog<span style="color: #990000">.</span><span style="font-weight: bold"><span style="color: #000000">open</span></span><span style="color: #990000">(</span>car<span style="color: #990000">).</span><span style="font-weight: bold"><span style="color: #000000">then</span></span><span style="color: #990000">((</span>color<span style="color: #990000">:</span> string<span style="color: #990000">)</span> <span style="color: #990000">=></span> <span style="color: #FF0000">{</span> + + <span style="font-weight: bold"><span style="color: #0000FF">this</span></span><span style="color: #990000">.</span><span style="font-weight: bold"><span style="color: #000000">applyColor</span></span><span style="color: #990000">(</span>color<span style="color: #990000">).</span><span style="font-weight: bold"><span style="color: #000000">then</span></span><span style="color: #990000">(</span> + + <span style="color: #990000">(</span>cost<span style="color: #990000">:</span> number<span style="color: #990000">)</span> <span style="color: #990000">=></span> <span style="font-weight: bold"><span style="color: #0000FF">this</span></span><span style="color: #990000">.</span><span style="font-weight: bold"><span style="color: #000000">addCost</span></span><span style="color: #990000">(</span>cost<span style="color: #990000">)</span> + <span style="color: #990000">)</span> + <span style="color: #FF0000">}</span><span style="color: #990000">);</span> + <span style="color: #FF0000">}</span><span style="color: #990000">);</span> +<span style="color: #FF0000">}</span></tt></pre></div></div> +</div> +</div> +<div class="sect1 slide"> <h1 id="_drum_roll_please_8230">Drum Roll Please 𥠅</h1> <div class="sectionbody" style="max-width:45em"> </div>