This file contains 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
// Translated from https://www.youtube.com/watch?v=bUy4xiJ05KY | |
import scala.collection.mutable.ListBuffer | |
var RUNNING: Option[() => Any] = None | |
class Signal[T](initial: T) { | |
private var _value = initial | |
private var observers = ListBuffer[() => Any]() |
This file contains 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
//> using scala 3.nightly | |
import language.experimental.namedTuples | |
type Person = (name: String, age: Int) | |
type Dog = (name: String, age: Int, breed: String) | |
type LivingThing = Person | Dog | |
@main | |
def main(): Unit = |
This file contains 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
type Primitive = Boolean | Int | Float | Double | Long | String | |
val x: Int = 1 | |
// x: Int = 1 | |
val y: String = "i" | |
// y: String = i | |
val z: Double = 1.0 | |
// z: Double = 1.0 | |
def primitiveMatch(x: Primitive) = |
This file contains 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 { useEffect, useRef } from 'react'; | |
/** | |
* Activate with a delay greater than zero | |
* The last callback is applied immediately | |
* | |
* Adapted from https://usehooks-ts.com/react-hook/use-interval | |
*/ | |
export function useInterval(callback: () => void, delay: number | null) { | |
const savedCallback = useRef(callback); |
This file contains 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
/* eslint-disable */ | |
type PipeFlow<Payload, Stage extends string> = { | |
stage: Stage | |
status: boolean | |
payload?: Payload | |
} | |
type FilterFunction<In = any, Out = any, Stage extends string = string> = (input: In) => PipeFlow<Out, Stage> |
This file contains 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
/* eslint-disable */ | |
type FilterFunction<In = any, Out = any> = (input: In, next: (flow: boolean, nextInput: Out) => any) => any | |
export function pipelineSync<FirstIn, FirstOut>(first: FilterFunction<FirstIn, FirstOut>) { | |
const pipeline: Array<FilterFunction> = [first] | |
const run = (input: FirstIn): any => pipeline | |
.reduceRight((nextFunc, currentFunc, index) => { |