Many of the more "advanced" typescript features can be used for creating "value-derived" types.
At its simplest form:
let vehicle = { name: "Van", wheels: 4 }
type SomeProps = | |
| { action: "START" } | |
| { action: "STOP"; time: number } | |
| { action: "PAUSE"; time: number; ref: { current: any } }; | |
function useExample(props: SomeProps) { | |
let { | |
action, // "START" | "STOP" | "PAUSE" | |
time, // number | undefined, | |
ref // { current: any } | undefined |
import { OperatorFunction } from 'ix/interfaces'; | |
import { pipe } from 'ix/iterable'; | |
import { map } from 'ix/iterable/operators'; | |
/** | |
* Creates a new type which is the first element of a non-empty tuple type. | |
* | |
* @example type T = Head<[string, number, Object]>; // string | |
*/ | |
export type Head<Ts extends [any, ...any[]]> = Ts extends [infer T, ...any[]] ? T : never; |
var list = []; | |
document.querySelectorAll("body *") | |
.forEach(function(elem){ | |
if(elem.getBoundingClientRect().width > document.body.getBoundingClientRect().width){ | |
list.push(elem.outerHTML.split('>')[0] + '>'); | |
} | |
}); | |
confirm( "these elements are wider than the viewport:\n\n " + list.join("\n") ) |
All of the below properties or methods, when requested/called in JavaScript, will trigger the browser to synchronously calculate the style and layout*. This is also called reflow or layout thrashing, and is common performance bottleneck.
Generally, all APIs that synchronously provide layout metrics will trigger forced reflow / layout. Read on for additional cases and details.
elem.offsetLeft
, elem.offsetTop
, elem.offsetWidth
, elem.offsetHeight
, elem.offsetParent
(by @andrestaltz)
If you prefer to watch video tutorials with live-coding, then check out this series I recorded with the same contents as in this article: Egghead.io - Introduction to Reactive Programming.
This code is modified from the excellent O'Reilly book "Functional JavaScript". You should buy it, I highly recommend it! Don't kid yourself into thinking this gist even remotely covers the great content from a 200+ page technical book on the subject; it doesn't. Buy the book and get the in-depth knowledge for yourself. It's worth it.
<?php | |
function gfc_customers_update_7001() { | |
//Move the scoreboard to the scoreboard region | |
db_update('block') | |
->fields(array( | |
'weight' => 2, | |
'region' => 'scoreboard_only', | |
)) | |
->condition('module', 'views') |
<?php | |
include_once DRUPAL_ROOT . "/sites/golfchanneldev.prod.acquia-sites.com/settings.php"; | |
$conf['stage_file_proxy_origin'] = 'http://www.golfchannel.com'; | |
$conf['refresh_score_pages'] = FALSE; | |
$conf['gfc_customers_api_golfnow_url'] = 'http://develop.gnsvc.com/V1.1/TeeTimesAPIRest.svc/'; | |
$conf['https'] = FALSE; | |
$cookie_domain = '.golfchannel.local'; | |
// $conf['securepages_basepath'] = 'http://golfchannel.local'; | |
// $conf['securepages_basepath_ssl'] = 'https://secure.golfchannel.local'; |