Saturday, July 22, 2017

Observable ABCs in the abstract

I am just over halfway through a series of online trainings on Angular 4 and it is starting to get into Observables. Today I learned some stuff so simple that there isn't really a praxis for it. Consider these imports:

import { Observable } from 'rxjs/Observable';
import 'rxjs/Rx';
import { Observable } from 'rxjs/Observer';


They will allow you to do something silly like this which will sequentially show you numbers counting up at the console:

const whatever = Observable.interval(1000);
   (numb: number) => {


Honestly, we didn't need Observer for what was immediately above, but let's loop that in now.

const fly = Observable.create((flyFu: Observer<string>) => {
   setTimeout(() => {'our fly is still alive after one second');
   }, 1000);
   setTimeout(() => {'our fly is yet still alive after two seconds');
   }, 2000);
   setTimeout(() => {
      flyFu.error('our fly has died');
   }, 3000);


Observer, which I had never heard of, lets me fake an asynchronous call against maybe a web socket as I never would. Yay! This naturally allows for:

   (yes: string) => {
   (no: string) => {
   () => {
      console.log('our fly is done');


The three cases above are of course:

  1. getting something back from an Observer successfully
  2. an error handling scenario
  3. something to happen upon completion that order. You will never see the completed scenario in running our code above. In order for that to happen the error jammed in a setTimeout would need to perhaps be changed up like so:

setTimeout(() => {
}, 3000);


Once the complete goes off there will be no further asynchronous activity. Expect no new successes or errors.

Friday, July 21, 2017

I hate the template tag in Angular 2.

<template ngFor let-foo [ngForOf]="stuff" let i="index"> vaguely like...

<ng-container *ngFor="let foo of stuff; let i=index">

See if an array of strings contains one string in particular in JavaScript!

var stuff = ["foo", "bar", "baz", "qux"];
if(stuff.indexOf("bar") > -1){


I guess this JavaScript is to move the scrollbars leftmost and topmost at the browser.

Wednesday, July 19, 2017

when publishing from Visual Studio 2015 and you want to change the username

  1. To publish, right-click on the startup project and pick "Publish..." at the Solution Explorer.
  2. By the time you see the "Web Deploy Client" dialog where you enter a password, it is too late to doctor up the username after the fact in spite of the fact that it appears that you may.

Instead between steps 1 and 2 above when you are at the Publish dialog box and you see...

  • Profile
  • Connection
  • Settings
  • Preview the upper left, click on "Connection" to change the username.

when you remote desktop (Microsoft Terminal Services Client) into Windows Server 2008 R2 and the desktop is just black

click Ctrl-Alt-End which is akin to doing Ctrl-Alt-Delete at the server (obviously you cannot just do Ctrl-Alt-Delete as it would apply to your own PC) Next, press "Cancel" which will solve your problem.

Tuesday, July 18, 2017

import {Http} from '@angular/http'; ...cannot fire and forget

You are going to have to hand back something like true or some other vapid placebo value from PUT and DELETE endpoints when using this Angular 2 means for AJAX and you cannot just have an endpoint that returns void. The only way I can see to get around this, should you not control the API you are consuming, is to wrap the Http implementation in a try/catch where the exception is swallowed so that when it blows up you do not see red at the console. Your endpoint (returning void) will still get hit.

   this.myHttpInstance.put(myUrl, {}, myOptions).toPromise();