Skip to content

Instantly share code, notes, and snippets.

View bs1180's full-sized avatar

Ben Smith bs1180

  • Vienna, Austria
View GitHub Profile
@bs1180
bs1180 / firebase-utils.coffee
Last active August 29, 2015 14:27 — forked from tlrobinson/firebase-utils.coffee
Higher-level classes for synchronizing a nested Firebase ref, FirebaseEventEmitter and FirebaseImmutable. Work in progress.
Firebase = require "firebase"
Immutable = require "immutable"
{ EventEmitter } = require "events"
# Recursively listens to Firebase ref for modifications and emits "add",
# "change", and "remove" events with a path and value (except for "remove")
class FirebaseEventEmitter extends EventEmitter
constructor: (url) ->
EventEmitter.call(@)
// Event capturing for Mithril.js
// Demo here: http://jsfiddle.net/barney/vsw8r3Lh/
m.capture = function capturingEventHandler( eventName, handler ){
function bindCapturingHandler( element ){
element.addEventListener( eventName, handler, true );
}
return function config( element, init ){
if( !init ) bindCapturingHandler( element );
};

Implementing TodoFRP in JavaScript

FRP to me means building your app by transforming values over time, from the input to the current state to the display.

This implementation is based on a the [graphics][1] library and is heavily inspired by [Elm][2]

A full implementation of TodoFRP can be found [online at Raynos/graphics example server][3]

Moving away from MVC

@bs1180
bs1180 / jolt-gist.js
Last active August 29, 2015 14:21 — forked from kaplas/jolt-gist.js
function notEmpty(val) {
return !_.isEmpty(val);
}
function valueAndValidFrom(observable, validator) {
validator = validator || notEmpty;
return {
valueS: observable.filter(validator),
validS: observable.map(validator)
};
If you can see this, you're viewing a Github gist.