This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| async function bootstrap() { | |
| const config = await fetch('http://localhost:3000/config').then( res => res.json() ); | |
| // You can provide static providers to the created platform | |
| const browserPlatform = platformBrowserDynamic([ | |
| { provide: ConsoleLogger } | |
| ]); | |
| // After bootstrapping your module you can use thק appModuleRef to configure | |
| // The module injector, and get access to this module components |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import VideoPlayer from "./VideoPlayer"; | |
| const App = () => ( | |
| <div> | |
| <h1>Declarative Usage</h1> | |
| {/* create context for a VideoPlayer */} | |
| <VideoPlayer> | |
| <VideoPlayer.Player src={"sample.mp4"}/> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Concept | |
| @Directive({ | |
| selector: 'introTip' | |
| }) | |
| class IntroTipDirective implements Oninit{ | |
| @Input('introTip') key: string; | |
| constructor(private hostElement: ElementRef, | |
| private interService; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // ******************************* | |
| // Just a wrapper around callbacks, | |
| // So we can use the same API - and state of mind | |
| // ******************************* | |
| // helper to create observable | |
| function createObservable(subscribe) { | |
| return { | |
| subscribe, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Holds a state (currentUser), end expose | |
| // methods to alter it | |
| class Auth { | |
| constructor() { | |
| this.currentUser = null; | |
| } | |
| signIn() { | |
| this.currentUser = {name: "Nir"}; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function renderElement(element) { | |
| const {type, props, children} = element; | |
| // component support | |
| if(typeof type === 'function') { | |
| return renderElement(type(props)); | |
| } | |
| const domElement = document.createElement(type); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import {Component} from '@angular/core'; | |
| import {Card, CardTypes} from "./cards/cards.types"; | |
| @Component({ | |
| selector: 'app-root', | |
| template: ` | |
| <div class="container m-5"> | |
| <ng-container *cardDeck="let card for cards; primary customPrimary"></ng-container> | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| enum Status {Received, Pending, InProcess, Sent, Delivered } | |
| enum Priority { Low, Medium, High, Urgent } | |
| interface Order { | |
| id: number; | |
| itemCount: number; | |
| ordered: string; | |
| expectedDelivery: string; | |
| status: Status, | |
| priority: Priority; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| let hooks = []; | |
| let idx = 0; | |
| export function useState(initialState) { | |
| let state = hooks[idx] || initialState; | |
| let _idx = idx; | |
| function setState(newState) { | |
| hooks[_idx] = newState; | |
| render(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const website = `nir.life` | |
| const btn = document.createElement('button'); | |
| function map(transformFn) { | |
| return function(inputValueProvider) { | |
| return createObservable( | |
| function (onValue, onError, onComplete) { | |
| inputValueProvider.subscribe( | |
| (value) => onValue(transformFn(value)), |