Skip to content

Instantly share code, notes, and snippets.

View hegelstad's full-sized avatar
🎯
Focusing

Nikolai Hegelstad hegelstad

🎯
Focusing
View GitHub Profile
@aliyeysides
aliyeysides / rxjs-switchMap-combineLatest-specimen.ts
Last active January 5, 2024 06:47
example use of .switchMap that streams value to multiple inner observables using static .combineLatest method
this.symbolSearchService.getSymbolData('xl')
.switchMap(stock => {
this.stock = stock;
return Observable.combineLatest(
this.symbolSearchService.getResearchReportData(stock),
this.symbolSearchService.getPGRDataAndContextSummary(stock)
)})
.subscribe(
[report, summary] => {
this.researchReport = report;
@domenic
domenic / interop.md
Last active July 7, 2022 19:47
`module.exports =` and ES6 Module Interop in Node.js

module.exports = and ES6 Module Interop in Node.js

The question: how can we use ES6 modules in Node.js, where modules-as-functions is very common? That is, given a future in which V8 supports ES6 modules:

  • How can authors of function-modules convert to ES6 export syntax, without breaking consumers that do require("function-module")()?
  • How can consumers of function-modules use ES6 import syntax, while not demanding that the module author rewrites his code to ES6 export?

@wycats showed me a solution. It involves hooking into the loader API to do some rewriting, and using a distinguished name for the single export.

This is me eating crow for lots of false statements I've made all over Twitter today. Here it goes.