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 renderImage(ctx, url, width, height): Promise<boolean> { | |
return new Promise((resolve) => { | |
fetch(url) | |
.then((res) => res.blob()) | |
.then((blob) => createImageBitmap(blob)) | |
.then((ibm) => { | |
ctx.drawImage(ibm, 0, 0); | |
resolve(); | |
}); | |
}); |
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 {Injector, Resolver} from "../src/diy/injector"; | |
import {RendererService} from "./services/renderer.service"; | |
class DiBootstrap { | |
static run() { | |
console.log('---------------- | START | -----------------'); | |
// Static injector |
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 {Ctr} from "../../../common/types"; | |
type ClazzDecorator<T> = (target: T) => void; | |
export const Injectable = () : ClazzDecorator<Ctr<any>> => { | |
return (target: Ctr<any>) => { | |
// this is needed so the design:paramtypes could be collected | |
console.log('inside: Injectable decorator'); | |
console.log(target.name, ' is used'); | |
}; |
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 'reflect-metadata'; | |
import {Ctr} from "../../../common/types"; | |
export class Injector { | |
private depInstances: Map<string, Ctr<any>> = new Map<string, Ctr<any>>(); | |
// Not storing an instances map | |
static resolve<T>(target: Ctr<any>): T { | |
const tokens = Reflect.getMetadata('design:paramtypes', target) || []; |
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
class FunWithFunctionalTS { | |
queryEditorState: Readonly<QueryEditorState>; | |
static updateEditorState( | |
editorState: Readonly<QueryEditorState>, | |
sliceToUpdate: Partial<Readonly<QueryEditorState>> | |
): Readonly<QueryEditorState> { | |
return { ...editorState, ...sliceToUpdate }; | |
} |
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
class updateEditorExample { | |
private queryEditorState: Readonly<QueryEditorState>; | |
static updateEditorState (editorState: Readonly<QueryEditorState>, sliceToUpdate: Partial<Readonly<QueryEditorState>>) { | |
return { ...editorState, ...sliceToUpdate }; | |
} | |
// Get new state: | |
doSomthingGood(newText: string) { |
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
#![allow(unused_variables)] | |
fn main() { | |
use wasm_bindgen::prelude::*; | |
// Called by our JS entry point to run the example | |
#[wasm_bindgen(start)] | |
pub fn rust_in_peace() -> Result<(), JsValue> { | |
// Use `web_sys`'s global `window` function to get a handle on the global | |
// window object. | |
let window = web_sys::window().expect("no global `window` exists"); |
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
input[type=checkbox] { | |
display: none; | |
} | |
.toggle-legend { | |
cursor: pointer; | |
} | |
input[type=checkbox]:checked ~ .groups-legend { | |
display: flex; | |
} | |
input:not(:checked) ~ .groups-legend { |
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, EventEmitter, Input, OnInit, Output } from '@angular/core'; | |
@Component({ | |
selector: 'toggle-btn', | |
template: ` | |
<label class='so-slide-toggle'> | |
<input (change)="onChange($event)" type="checkbox"/> | |
<span class="back"> | |
<span class="toggle"></span> | |
<span class="label on" [title]="enabledText">{{ enabledText }}</span> |
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, Input, OnInit, ViewEncapsulation} from '@angular/core'; | |
import {SillyButtonService} from './silly-button.service'; | |
@Component({ | |
// tslint:disable-next-line:component-selector | |
selector: 'ng-silly-button', | |
template: | |
`<div class="silly-btn" (click)="onClick($event)"> | |
<div class="content"> | |
<ng-content></ng-content> |