Skip to content

Instantly share code, notes, and snippets.

View leonkaihao's full-sized avatar

Kai Hao leonkaihao

View GitHub Profile
@leonkaihao
leonkaihao / channel.ts
Last active August 6, 2020 09:34 — forked from iwasaki-kenta/channel.ts
Go-like channels in TypeScript.
import { Subject } from 'rxjs';
export class Deferred<T> {
promise: Promise<T>;
resolve!: (value?: T | PromiseLike<T>) => void;
reject!: (reason?: any) => void;
constructor() {
this.promise = new Promise<T>((resolve, reject) => {
this.resolve = resolve;

Keybase proof

I hereby claim:

  • I am leonkaihao on github.
  • I am leonkaihao (https://keybase.io/leonkaihao) on keybase.
  • I have a public key ASAquB6RLFqRJH-inSmo7hLTZmAV1wIOoeJ_CHEmUoKQ_Qo

To claim this, I am signing this object: