Skip to content

Instantly share code, notes, and snippets.


André Staltz staltz

View GitHub Profile
View tiny-cycle-1.js
function main() {
return {
DOM: Rx.Observable.timer(0, 1000)
.map(i => `Seconds elapsed ${i}`)
const drivers = {
DOM: function DOMDriver(sink) {
sink.subscribe(text => {
staltz /
Last active Dec 28, 2018
How to show migration guides in GitHub Markdown

How to show migration guides in GitHub Markdown

Use the diff code highlighting tag.

  - foo
  + bar


View divs.js
h('div.container', [
h('label.nameLabel', 'Name:'),
h('input.myinput', {attributes: {type: 'text'}}),
h('h1.greeting', `Hello ${name}`)
// or
div('.container', [
staltz / slim-cycle-core.js
Created Sep 22, 2015
Cycle.js without sanity checks and comments in a single file. Don't use this, use normal Cycle.js. :-)
View slim-cycle-core.js
let Rx = require(`rx`)
function makeRequestProxies(drivers) {
let requestProxies = {}
for (let name in drivers) {
if (drivers.hasOwnProperty(name)) {
requestProxies[name] = new Rx.ReplaySubject(1)
return requestProxies
staltz / scope.js
Last active Aug 31, 2015 — forked from axefrog/scope.js
An idea for scoping Cycle.js child components/dialogues in the context of their parent. Any driver can optionally supply a scope() function, which returns a scoped instance of itself. A driver can also supply an unscope() function which returns a transformed instance of its associated sink. Anything that is scope-unaware is preserved.
View scope.js
function runInScope(main, sources, context, ...args) {
if(!main) {
throw new Error('A "main" function must be supplied, which will be called in scope and from which a (sinks) object will be returned');
if(!sources) {
throw new Error('A source drivers object must be supplied, to which scoping can be applied');
if(!context) {
throw new Error('A scope context object must be supplied, either as a string, or as an object of key/value pairs');
staltz / jsx-quasi.js
Last active Aug 29, 2015 — forked from lygaret/index.js
ES6 Quasi-Literal for JSX
View jsx-quasi.js
define(function(require) {
var React = require('react');
var paramRegex = /__(\d)+/;
var parser = new DOMParser();
var errorDoc = parser.parseFromString('INVALID', 'text/xml');
var errorNs = errorDoc.getElementsByTagName("parsererror")[0].namespaceURI;
// turns the array of string parts into a DOM
// throws if the result is an invalid XML document.
staltz / router.js
Last active Aug 5, 2019 — forked from axefrog/router.js
Simple router driver for Cycle.js utilising Router5 for routing functionality and adapting some of the code from VisionMedia's Page.js for automatic link click intercepting
View router.js
'use strict';
import {Router5, RouteNode} from 'router5';
import logger from '../logger';
// The set of valid sink functions includes synchronous state-affecting router functions that do not require a callback
// and which do not have a significant return value other than the router object itself.
const validSinkFuncs = ['add','addNode','canActivate','deregisterComponent','navigate','registerComponent','setOption','start','stop'];
function validateAndRemapSinkArgument(arg) {
staltz / app.js
Created Jun 28, 2015
Draft of Cycle.js HTTP Driver
View app.js
const Cycle = require('@cycle/core');
const CycleWeb = require('@cycle/web');
const makeHTTPDriver = require('@cycle/http');
const h = CycleWeb.h;
function main(responses) {
// This essentially models when search requests are supposed
// to happen
staltz / app.kt
Last active Jan 26, 2018
Cycle giving baby steps into Kotlin
View app.kt
import kotlin.browser.document
import kotlin.browser.window
// Type definitions
val Cycle : dynamic = noImpl
fun h(tagName: String) : VTree = noImpl
View dom$.js
import Cycle from 'cyclejs';
const { h, Rx } = Cycle;
// all html/svg element names <<
var elements = [
You can’t perform that action at this time.