Skip to content

Instantly share code, notes, and snippets.

import { StateSoruce, Reducer } from '@cycle/state'
import { Stream } from 'xstream'
import { DOMSource, VNode } from '@cycle/dom'
import { HTTPSource, Request } from '@cycle/http'
type Payload = object
interface StoreState = {
userProfile: object
}
import { StateSoruce, Reducer } from '@cycle/state'
import { Stream } from 'xstream'
import { DOMSource, VNode } from '@cycle/dom'
import { HTTPSource, Request } from '@cycle/http'
type Payload = object
interface StoreState = {
userProfile: object
}
# Cyclic
foo --> bar --> baz --> bacon --> eggs
| |
<-- startWith <--
# Acyclic
foo -----------------------> bar --> baz --> bacon --> eggs
| |
PLACEHOLDER --> startWith --> |
|
interface Action<K extends keyof typeof ops> {
action: K;
data: (typeof ops[K]) extends (arg: infer T) => any ? T : undefined
}
const ops = {
setFire: (data: { place: string }) => data,
extinguish: (data: { extinguisherType: string }) => data
}
portToBackground.onMessage.addListener(function (messages: BackgroundMessage) {
// alert('LAUNCHER relaying message from BACKGROUND to PANEL: ' + JSON.stringify(message))
if (message.type === 'panelData' && typeof panelWindow['postMessage'] === 'function') {
panelWindow['postMessage']({__fromCyclejsDevTool: true, data: message.data}, '*');
} else if (message.type === 'tabLoading'
&& message.tabId === chrome.devtools.inspectedWindow.tabId) {
const settings = `
window.CyclejsDevToolSettings = ${JSON.stringify(sessionSettings)};
`;
chrome.devtools.inspectedWindow.reload({
export function mix<
COMB extends {
[CS in keyof ComponentSinks]?: (arg: {
[K in keyof COMPONENTS]: Stream<any>
}) => ComponentSinks[CS]
},
COMPONENTS extends {
[COMPNAME in keyof COMPONENTS]: {
[SINKNAME in keyof ComponentSinks]?: (COMB[SINKNAME] extends (arg: infer STREAMS) => any ? (
COMPNAME extends keyof STREAMS ? STREAMS[COMPNAME] : ComponentSinks[SINKNAME]
export function mix<
COMB extends {
[CS in keyof ComponentSinks]?: (arg: {
[K in keyof COMPONENTS]: Stream<any>
}) => ComponentSinks[CS]
},
COMPONENTS extends {
[COMPNAME in keyof any]: {
[SINKNAME in keyof ComponentSinks]?: (COMB[SINKNAME] extends (arg: infer STREAMS) => any ? (
STREAMS extends Hash<any> ? (
export function mix<
COMB extends {
[CS in keyof ComponentSinks]?: (arg: {
[K in keyof COMPONENTS]: Stream<any>
}) => ComponentSinks[CS]
},
COMPONENTS extends {
[COMPNAME in string]: {
[SINKNAME in keyof ComponentSinks]?: (COMB[SINKNAME] extends (arg: infer STREAMS) => any ? (
STREAMS extends Hash<any> ? (
type Dict<T> = { [key: string]: T }
interface component {
bacon: Stream<string>
lettuce?: Stream<number>
}
type baconArgs = {
firstBastard: Stream<string>,
secondBastard: Stream<string>
mix({
foo: {
bacon: 'stuff'
},
baz: {
bacon: 123,
lettuce: 'what'
}
}, {
bacon: ({foo: string, baz: number}): void => {},