JavaScript does not allow you to overload a function
function add(a: number[], b: number[]): number {
let sum = (acc,val)=>acc+val;
return a.reduce(sum,0) + b.reduce(sum,0)
}
function add(a: string, b: string) : string{
return a + b;
}JavaScript does not allow you to overload a function
function add(a: number[], b: number[]): number {
let sum = (acc,val)=>acc+val;
return a.reduce(sum,0) + b.reduce(sum,0)
}
function add(a: string, b: string) : string{
return a + b;
}| // Source code licensed under Apache License 2.0. | |
| // Copyright © 2017 William Ngan. (https://github.com/williamngan/pts) | |
| window.demoDescription = "A retro-style dazzling effect created by a grid whose cells change color and size based on their distances to the pointer."; | |
| Pts.quickStart( "#pt", "#123" ); | |
| //// Demo code starts (anonymous function wrapper is optional) --- | |
| (function() { |
Another way we can approach passing data down into Vue, is instead of passing in an object like
<SomeComponent :contact="contact"/>
and in SomeComponent needing to do
{{contact.firstName}}
| export enum SomeActions { | |
| AGE_ACTION = 'AGE_ACTION', | |
| NAME_ACTION = 'NAME_ACTION', | |
| LASTNAME_ACTION = 'LASTNAME_ACTION' | |
| } | |
| interface Age extends Action { | |
| type: SomeActions.AGE_ACTION; | |
| payload: { | |
| age: number; | |
| } |
Focus on speed - rendering, 2.5x faster, re-render, 4.2x faster
template compiler - can have an offline compile step, generate optimized javascript
Angular 2 - currently, kind of big - 170k, angular1 - was 56k, ng2 - down to 45k
improved lazy loading of routes
angular universal - server side rendering improvement, sends on the server side - sends out just HTML/css
first payload comes down - start streaming full JS to actually run the app
can include a preboot script that records user actions - that replays once everything is ready
| import {Component} from 'angular2/core'; | |
| import Modal from './modal'; | |
| @Component({ | |
| selector: 'ngc-app', | |
| template: ` | |
| <div class="p3"> | |
| <p class="p4"> | |
| <button class="btn btn-primary block col-6 mx-auto" | |
| (click)="showModal()"> |
| import {Injectable, Inject} from 'angular2/core'; | |
| import {BehaviorSubject} from 'rxjs/Rx'; | |
| @Injectable() | |
| export default class StateService { | |
| store: any; | |
| _ngRedux: any; | |
| constructor(@Inject('ngRedux') ngRedux) { | |
| this.store = this.observableFromStore(ngRedux); | |
| this._ngRedux = ngRedux; |
| import { is } from 'immutable' | |
| let x = 0; | |
| let tasksTest$ = this.stateService.select(state=> state.tasks, is).subscribe(n=> { | |
| console.log('this is called... yeah',++x) | |
| }) |