Skip to content

Instantly share code, notes, and snippets.

@branneman
branneman / 1.js
Last active May 6, 2023 08:11
JavaScript examples: No coupling, Loose coupling, Tight coupling
{
// Tight coupling from A to B => A needs B to be defined, callable and adhere to an interface
// No coupling from B to A => B does not need A in any way (pure fn)
function a() {
b()
}
function b() {}
}
{
@Lucifier129
Lucifier129 / algebraic-effects.js
Created June 28, 2018 14:33
algebraic effects and handlers for promise and observable
import { interval, isObservable } from 'rxjs'
import { tap } from 'rxjs/operators'
const type = {
isThenable: obj => !!(obj && typeof obj.then === 'function'),
isObservable: obj => !!(obj && isObservable(obj)),
isError: obj => obj instanceof Error,
isObject: obj => obj != null && typeof obj === 'object'
}