Skip to content

Instantly share code, notes, and snippets.

View jvanbruegge's full-sized avatar

Jan van Brügge jvanbruegge

View GitHub Profile
@jvanbruegge
jvanbruegge / todo.js
Last active April 11, 2017 08:05
A simple todo test in Cyclejs and xstream
import {
div, span, p, input, ul, li, button, body
}
from '@cycle/dom'
import xs from 'xstream'
export function Todo(sources) {
const action$ = intent(sources.DOM);
const model$ = action$
.fold((state, reducer) => reducer(state), {
@jvanbruegge
jvanbruegge / stream.ts
Last active August 12, 2017 20:42
Stream implementation
export interface Source<T> {
subscribe(o: Observer<T>): any;
}
export class ArraySource<T> implements Source<T> {
constructor(private array: T[]) {}
public subscribe(observer: Observer<T>): any {
this.array.forEach(t => observer.next(t));
}
@jvanbruegge
jvanbruegge / app.tsx
Created August 30, 2017 22:19
onionify-collection, no initial state
import xs, { Stream } from 'xstream';
import { VNode, DOMSource } from '@cycle/dom';
import { StateSource } from 'cycle-onionify';
import { Sources, Sinks } from './interfaces';
import { Counter, AppState as ChildState } from './counter'
export type AppSources = Sources & { onion : StateSource<AppState> };
export type AppSinks = Sinks & { onion : Stream<Reducer> };
export type Reducer = (prev : AppState) => AppState;
{-# LANGUAGE CPP #-}
{-# LANGUAGE OverloadedLabels #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE TypeOperators #-}
module Main where
-- #define SUPERRECORD
#define MEGARECORD
@jvanbruegge
jvanbruegge / withLocalState.ts
Created April 4, 2019 13:15
My withLocalState combinator, soon to be published seperately
type SimpleMerge<Global, Local> = { global: Global, local: Local };
interface Merger<Global, Local, T> {
merge(g: Global, l: Local): T;
extract(t: T): SimpleMerge<Partial<Global>, Partial<Local>>;
}
function withLocalState<Global, Local, T = SimpleMerge<Global, Local>>(component: Component<T>, merger?: Merger<Global, Local, T>, stateChannel = 'state', localChannel = '_localState'): Component<Global> {
const defaultMerger: Merger<Global, Local, SimpleMerge<Global, Local>> = {
merge: (global, local) => ({ global, local }),
extract: identity
apiVersion: v1
kind: Namespace
metadata:
name: haproxy
---
apiVersion: v1
kind: ServiceAccount
metadata:
name: ingresses-controller
namespace: haproxy