Thursday, February 15, 2018

things learned at another Angular/TypeScript training at work yesterday

When using const and let, try to use const first. There can only be one constructor in JavaScript/TypeScript. The method overloading tricks of C# wherein you may have different signatures for a constructor will not work in JavaScript/TypeScript. The three accessibilities in TypeScript are private, public, and protected and they more or less behave as they do in C#. Object literals are sort of anonymously-shaped object requirements which this suggests look like so:

var obj: { property: string; } = { property: "foo" };

 
 

Interfaces are sort of the same thing only less anonymous. The have a reusable type associated with them. The Redux store paradigm is to keep state across multiple components from splinting and growing apart across multiple components. That is the problem it solves. Subscriptions in Observables should probably be avoided. You have to remember to tear them down in an ngOnDestroy at a component. (Use ngOnDestroy as a destructor.) When doing a .subscribe off of params in routing like so you don't need the destructor though. There is no bubbling up of events in Angular. If you have a bunch of components nested in a Russian dolls manner and the inner most thing needs to raise an event to the outermost thing you have to write boilerplate code for every step up at every component along the way to catch and rethrow events. (Use EventEmitter.) It is appropriate vernacular to say that when you navigate to a route that you activate it. A URL matcher will allow you to do RegEx stuff to make sense of routes. (pathMatch can either be full or prefix for a path) Start with specific routes and downstream in the routing module have more generic ones to cast a wider net. routerLink lets you specify a tag instead of the default router-outlet that will be hydrated for subrouting so to speak and the setting may either be a string literal (something enclosed in either single or double quotes) or a something built up from an array. Per this you may use outlets to have routing affect two content areas like so:

[routerLink]="['/speakers', {outlets: {'list': ['speakersList'], 'bio': ['none']}}]"

 
 

The CanLoad guard is like the CanActivate guard only if you get booted from the CanLoad approach then the content you never saw also never got lazy loaded. Resolvers are a thing. There is a Resolve guard for these. A router gets looped in as a service at a constructor of a component to have at things like params therein. This touches on matrix URLs (allows for seperators in routes) somewhat, another way to craft URLs in the HTML spec.

No comments:

Post a Comment