Friday, March 24, 2017

Angular 4 is available as of yesterday!

Don't worry, the leap from 2 to 4 is not as big as the leap from 1 to 2. This is not another rewrite. The AOT generated code gets less verbose. *ngIf and *ngFor change some too. See: this ...I tried to get the application described here, here, and here onto 4.0.0 by doctoring up package.json to have a 4.0.0 in place of all of the ~2.1.1 stuff and the ~3.1.1 for routing (by the way the leap to 4 from 2 is to get the routing on the same new version as everything else) but when I hydrate dependencies anew I can't get the app to run. They is something else that is messed up. By the way the tilde means use this minor version at the highest version possible and the carat (instead of the tilde at package.json) means use this major version at the highest version possible.

Thursday, March 23, 2017

Always leave the campground cleaner than you found it?

Is this really good policy? I knew a guy who lost his job because he would refactor code beyond the scope of what really needed to be fixed. What if you're breaking things in the name of making them better?

feature gating

...is of the ability to turn a feature back off after you roll it out and realize that it sucks.

Default and OnPush are the two varieties of ChangeDetectionStrategy.

The OnPush approach will turn off all of the watchers and your data will only update when an input change.

@Component({
   template: `
      <h2>{{vData.name}}</h2>
      <span>{{vData.email}}</span>
   `,
   changeDetection: ChangeDetectionStrategy.OnPush
})
class VCardCamp {
   @Input() vData;
}

 
 

More about the above:

  1. template in an Angular 2 component may be replaced with templateUrl to reference an .html file
  2. The backtick thing above for string formating is real. It's the key above Tab, not the key left of the Enter. Use single curly braces and a leading dollar sign for this sort of formatting in TypeScript standalone:
    let foo: number;
    foo = 13;
    let bar: string;
    bar = `A baker's dozen has ${foo} donuts in it!`
    alert(bar);

Wednesday, March 22, 2017

A constructor variable at an Angular 2 component not decorated with public or private cannot be seen beyond the constructor.

The ref variable here is an example, not the zone variable.

constructor(ref: ChangeDetectorRef, private zone: NgZone) {

Put a function in your Microsoft.PowerShell_profile.ps1 file at the WindowsPowerShell folder!

In this locale you may roll something like this:

#This is a function in a PowerShell .ps1 file!
function Do-Something {
[CmdletBinding()]
param(
   [switch]$foo,
   [switch]$bar,
   [switch]$baz,
   [String]$qux=""
)
PROCESS {
      Write-Host "doing the something..." -foreground yellow
      if ($baz) {
         $foo = $true;
         $bar = $true;
      }
      if ($foo) {
         Write-Host "either foo or baz was flagged" -foreground yellow
      }
      if ($bar) {
         Write-Host "either bar or baz was flagged" -foreground yellow
      }
      if ($qux.length -gt 0) {
         Write-Host $qux "was handed in for qux" -foreground yellow
      }
   }
}

 
 

From the PowerShell command line the function could be called in the following legitimate ways (amongst others) and you can probably guess what each does.

  • do-something
  • do-something -foo
  • do-something -bar
  • do-something -baz
  • do-something -qux "whatever"
  • do-something -foo -qux "whatever"

 
 

Every time you change the script you must close and reopen the PowerShell console to see the newness.

xUnit.net

This is yet another testing framework not unlike NUnit. You write unit tests for it and what not. It is .NET flavored.