Skip to content

Instantly share code, notes, and snippets.

@foxdonut
foxdonut / README.md
Created November 30, 2015 19:16
Simple React Hello World

Simple React Hello World

Run these commands:

npm i
npm start

You only have to run npm i the first time.

Meiosis Routing with Mithril Router
@foxdonut
foxdonut / index.ios.js
Created November 23, 2016 21:59
Meiosis on React-Native
import React, { Component } from 'react';
import { AppRegistry, Button, StyleSheet, Text, View } from 'react-native';
import { createComponent, run } from "meiosis";
// This is from the React Native hello world example.
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
[ button
[ class "btn btn-primary btn-xs"
, onWithOptions
"click"
{ preventDefault = True, stopPropagation = False }
targetValue
(always (Signal.message address (Save model.todo)))
]
[ text "Save" ]
import Html exposing (Html, button, div, text)
import Html.Events exposing (onClick)
type alias Model = String
type Action
= NoOp
| Show Model
@foxdonut
foxdonut / index.js
Created February 10, 2016 13:38
requirebin sketch
// require() some stuff from npm (like you were using browserify)
// and then hit Run Code to run it on the right
var most = require("most");
var h = require("virtual-dom/h");
var diff = require("virtual-dom/diff");
var patch = require("virtual-dom/patch");
var createElement = require("virtual-dom/create-element");
var match = function(query) {
return function(evt) {
can.Model({
findAll: function(params) {
var dfd = new can.Deferred();
$.get("/abc", params, function(response) {
dfd.resolve(response.model);
});
return dfd.promise();
}
function(chain) {
return function(req) {
doSomethingBefore(req);
chain(req);
doSomethingAfter(req);
};
}
(fn [chain]
(fn [req]
(do-something-before req)
(chain req) ; continue the chain -- you could potentially not call this to interrupt the chain
(do-something-after req)))