(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.
(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.
| const flatMap = (fn, stream, resultSelector) => | |
| stream.flatMap((x, xi) => fn(x).map((y, yi) => resultSelector(x, y, xi, yi))); | |
| const flatMapLatest = (fn, stream) => | |
| stream.publish(s => s.flatMap(v => fn(v).takeUntil(s))); | |
| const flatMapLatest = (fn, stream, resultSelector) => stream.publish(s => { | |
| return s.flatMap(v => fn(v), resultSelector).takeUntil(s)); | |
| }); |
| /** | |
| Taken from: http://stackoverflow.com/questions/588040/window-onload-vs-document-onload | |
| According to Parsing HTML documents - The end, | |
| The browser parses the HTML source and runs deferred scripts. | |
| A DOMContentLoaded is dispatched at the document when all the HTML has been parsed and have run. The event bubbles to the window. | |
| The browser loads resources (like images) that delay the load event. | |
| A load event is dispatched at the window. | |
| Therefore, the order of execution will be | |
| DOMContentLoaded event listeners of window in the capture phase | |
| DOMContentLoaded event listeners of document |
| // zip arrays together | |
| // Catalin Dumitru @colin_dumitru | |
| // Jason Awbrey @jsawbrey | |
| const zip = (a, b) => a.map((n, i) => [n, b[i]]) | |
| // merge objects in an array together | |
| // caution: properties are overridden if duplicated | |
| // @a [{a},{b}] | |
| // @returns [{a, b}] | |
| // Jason Awbrey @jsawbrey |
| export type Matcher<T> = (query: string) => T[]; | |
| export type ValueProject<T> = (target: T) => Array<string | number>; | |
| export type MatcherFactory = <T>(targets: T[], project: ValueProject<T>) => Matcher<T>; | |
| export const defaultProject = <T>(target: T) => Object.values(target); | |
| const isMatchable = prop => typeof prop == 'number' || typeof prop == 'string' | |