Skip to content

Instantly share code, notes, and snippets.

@iazel
iazel / yaml-updater.rb
Last active August 29, 2015 14:02
YAML Updater
#!/usr/bin/env ruby
# encoding: UTF-8
require 'yaml'
require 'delegate'
class TagNew < SimpleDelegator
def object_class
__getobj__.class
end
@iazel
iazel / Title-terse.ts
Created May 29, 2019 21:03
Todos Example
import { ht } from '@crui/core'
export const Title = ht('h1', 'TODO App')
@iazel
iazel / Title.ts
Created May 29, 2019 21:07
Todo / Title
import { hc, text } from '@crui/core'
const Title = hc('h1', [
text('TODO App')
])
@iazel
iazel / todo-input-classname.ts
Last active July 11, 2019 20:14
Composable Reactive UI
import { h, props } from '@crui/core';
const input = h('input', props({ className: 'add-todo-submit' }))
@iazel
iazel / input.ts
Created July 11, 2019 20:23
Composable Reactive UI / Input with event
import { h, sc2, props, on } from '@crui/core'
const input = h('input', sc2(
props({ className: 'add-todo-submit' }),
on('input', (e) => doSomething(e)),
))
@iazel
iazel / input.ts
Created July 11, 2019 20:30
Composable Reactive UI / Input reactive
import { h, sc2, props } from '@crui/reactive/elems'
import { StreamBox } from '@crui/reactive/rx/box'
import { bindValue } from '@crui/reactive/setups/bind'
const $box = new StreamBox('')
const input = h('input', sc2(
props({ className: 'add-todo-input' }),
bindValue($box)
))
@iazel
iazel / submit.ts
Last active July 11, 2019 20:46
Composable Reactive UI / Submit
import { h, sc, props, onClick, ctext } from '@crui/core'
const submit = h('button', sc([
ctext('Add')
props({ className: 'add-todo-submit' }),
onClick((e) => {
e.preventDefault()
// what to do?
}),
@iazel
iazel / submit.ts
Last active July 11, 2019 20:54
Composable Reactive UI / Submit done
import { h, sc, props, onClick, ctext } from '@crui/core'
import { StreamBox } from '@crui/reactive/rx/box';
type AddTodo = (todo: string) => void
const submit = (todo: StreamBox<string>, addTodo: AddTodo) => (
h('button', sc([
ctext('Add')
props({ className: 'add-todo-submit' }),
onClick((e) => {
e.preventDefault()
@iazel
iazel / store.ts
Created July 11, 2019 20:58
Composable Reactive UI / TodoStore
import { StreamBox, RW$B } from '@crui/reactive/rx/box';
export type Todo = {
text: string,
}
export type TodoList = Todo[]
export class TodoStore {
@iazel
iazel / submit.ts
Created July 11, 2019 21:20
Composable Reactive UI / Submit with Store
const submit = (store: TodoStore) => (
h('button', sc([
ctext('Add')
props({ className: 'add-todo-submit' }),
onClick((e) => {
e.preventDefault()
store.addTodo(todo.get())
store.getInput().set('')
}),
]))